Jump to content

Recommended Posts

Hi,

I made a small php configuration that runs a cmd command that is designed to create a Scheduled Task on Windows.

Code snippet

$createTaskCmd = "schtasks.exe /CREATE /SC MONTHLY /D 15 /TN mytask /TR C:\Windows\System32\notepad.exe /ST 00:00:10 /f /RU System";
	shell_exec($createTaskCmd);

keep in mind I also tried using, 'exec' and I also tried out this solution. I'm trying to create a temporary task and have it be destroyed much later. 

2 minutes ago, requinix said:

And your question is...?

Oh yeah, I may have missed out on a few things. 

The code essentially doesn't work. I've tried variations of it running on a localhost xampp configuration. When I load the localhost webpage it doesn't show my task on the task list. 

capturetemp.PNG.e97b2f481e28aecd4abe445c84134191.PNG

The task, "mytask" is nowhere to be found when I run the php file. I know the command is correct because it works via, custom batch file but I need the command to run from a php script. The name of the task will be manipulated in the future.

Ive tried running another simple configuration in order to prove whether php was capable of running batch commands. 

shell_exec('mkdir testdir');

So simple commands such as creating a directory works with php shell_exec. But I cant get it to create a cron job using the Windows Task Scheduler.

 





 

7 minutes ago, requinix said:

Are you sure the user that the web server is running as has the permission to create tasks under the SYSTEM account? See if you can create one without any associated user information.

Can you tell me where I can find the list of accounts. Is it under users? C:\Users?  

Regarding your question  how do I manipulate the permissions so the user can create tasks?  

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.