| 
	
 | 
 Posted by vol30w60 on 04/10/07 20:47 
vol30w60 wrote: 
> Schraalhans Keukenmeester wrote: 
>> vol30w60 wrote: 
>>> Hi folks, 
>>> 
>>> I am trying to launch a program with PHP code. I am running Apache on 
>>> Windows XP SP2. 
>>> 
>>> I am using the method noted here: 
>>> http://us2.php.net/manual/en/function.exec.php#59428 
>>> 
>>> To simplify things, I am trying to launch notepad with the following 
>>> line of code: 
>>> 
>>> <?php 
>>> 
>>> exec('C:\PsTools\psexec.exe -d -s notepad.exe 2>&1', $output); 
>>> 
>>> ?> 
>>> 
>>> I can see psexec running in the Task Manager, but it does not launch 
>>> notepad and does not return control to PHP. If I manually quit psexec 
>>> from the Task Manager, PHP will resume executing the script. 
>>> 
>>> Running this from the command line works fine: 
>>> C:\PsTools\psexec.exe -d -s notepad.exe 2>&1 
>>> 
>>> If I force quit psexec and do a var_dump() on $output, I see: 
>>> 
>>> array(5) { [0]=> string(0) "" [1]=> string(41) "PsExec v1.82 - Execute 
>>> processes remotely" [2]=> string(40) "Copyright (C) 2001-2007 Mark 
>>> Russinovich" [3]=> string(35) "Sysinternals - www.sysinternals.com" 
>>> [4]=> string(0) "" } 
>>> 
>>> Note that there is no error message, but the expected output should have 
>>> a sixth line something like this: 
>>> notepad.exe started on HAL with process ID 4668. 
>>> 
>>> Any ideas on how I can get this to work? 
>>> 
>>> 
>> Which user shows in TaskManager running psexec (and Notepad?) when run 
>> from PHP vs. from commandline? I don't know the program psexec btw. Is 
>> that a must-use for exec-ing stuff in windows from apache? 
>> 
>> Sh. 
>  
> Thanks for the reply. 
>  
> psexec.exe runs under my user account from the command line. I can  
> control which user runs notepad.exe from the command line using the -s  
> flag for System, or I can specify a different user with the -u and -p  
> flags. 
>  
> psexec.exe runs as System from PHP. 
>  
> It makes me wonder if this is related to access privileges, but I don't  
> know what the correct settings are. Do all the executables have to be in  
> the same directory? Do I have to configure PHP with certain access  
> privileges? I'm not very skilled with these settings on Windows. 
>  
 
Success! -- and I cannot believe how ridiculous this was. Apparently,  
psexec.exe will not run until you accept the EULA. To do that, you need  
to add the flag -accepteula to your command string! I did not see this  
mentioned anywhere in the documentation, but I found the solution on a  
message board after much searching. Hope this helps someone else.
 
  
Navigation:
[Reply to this message] 
 |