denerex Posted April 19, 2021 Share Posted April 19, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/312489-help-with-setting-scheduled-task-with-php-windows-10/ Share on other sites More sharing options...
requinix Posted April 19, 2021 Share Posted April 19, 2021 And your question is...? Quote Link to comment https://forums.phpfreaks.com/topic/312489-help-with-setting-scheduled-task-with-php-windows-10/#findComment-1585918 Share on other sites More sharing options...
denerex Posted April 19, 2021 Author Share Posted April 19, 2021 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. 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. Quote Link to comment https://forums.phpfreaks.com/topic/312489-help-with-setting-scheduled-task-with-php-windows-10/#findComment-1585919 Share on other sites More sharing options...
requinix Posted April 19, 2021 Share Posted April 19, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/312489-help-with-setting-scheduled-task-with-php-windows-10/#findComment-1585920 Share on other sites More sharing options...
denerex Posted April 19, 2021 Author Share Posted April 19, 2021 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? Quote Link to comment https://forums.phpfreaks.com/topic/312489-help-with-setting-scheduled-task-with-php-windows-10/#findComment-1585923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.