[SOLVED] shell_exec schtasks password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rcmn
Forum Newbie
Posts: 21
Joined: Tue Jul 06, 2004 10:35 am

[SOLVED] shell_exec schtasks password

Post by rcmn »

Server config :win2k3/apache/PHP 5.2.1

if i login via remote control and run this command in a prompt

Code: Select all

schtasks /create /tn mytask01 /tr c:\taskas.bat /sc once /st 16:32:00 /sd 10/19/2007 /ru MyDomaine\myusername /rp mypassword
A task will be created and run properly.

but if i tried via PHP using the following 2 differents options a task is created but the password is not set in the task.
So the task will fail to run.

Code: Select all

$echos = shell_exec("schtasks /create /tn mytask01 /tr c:\taskas.bat /sc once /st 16:32:00 /sd 10/19/2007 /ru MyDomaine\myusername /rp mypassword");
i get the following error in apache log:

Code: Select all

WARNING: The scheduled task "mytask01" has been created, but may not run because the account information could not be set.

Code: Select all

$runCommand = "schtasks /create /tn mytask01 /tr c:\taskas.bat /sc once /st 16:32:00 /sd 10/19/2007 /ru MyDomaine\myusername /rp mypassword";
$WshShell = new COM("WScript.Shell");
$output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
I don't get any errors log in apache

For troubleshooting :
-I tried to run the apache service as locale admin account or domain admin account. (still doesn't fix the pbm).
-tried different syntax (found in google).(no better)
Last edited by rcmn on Mon Oct 22, 2007 1:38 pm, edited 1 time in total.
rcmn
Forum Newbie
Posts: 21
Joined: Tue Jul 06, 2004 10:35 am

Post by rcmn »

fixed using

schtasks /create /tn mytask01 /tr c:\\taskas.bat /sc once /st 16:32:00 /sd 10/19/2007 /ru MyDomaine\\myusername /rp mypassword

it was a syntax issue on my part.
Post Reply