简体   繁体   中英

Exec Command not Working in PHP

I am simply trying to run an executable file from a PHP script. Seems simple enough but it just will not work for me. I have tried both of these methods:

$oExec = $WshShell->Run("Notepad.exe >> /err.txt"); 

and

exec("Notepad.exe >> /err.txt");

without success. Nothing seems to happen, I step through my code and the lines execute but notepad does not open. Err.txt is empty so there is no help there and I can't find an error anywhere. I would think if it was a permissions issue I would get an error message, and other than that I'm not sure what the problem can be. It seems to find Notepad.exe ok because when I write Ntpad.exe I get an error. Any help would be greatly appreciated.

The script is running from a local IISExpress site.

After much frustration I figured out the answer, thanks to Cheery for letting my know that Notepad would never show up without desktop interaction I would have been there for a while trying to figure out why it wasn't working. There was a few problems with my original script...

$oExec = $WshShell->Run("cmd C:\Test\ffmpeg -i C:\Test\ferrisglennnews.mov video.webm"); 
  1. double slashes are needed
  2. cmd must be removed
  3. not having a directory puts the output in the default cmd directory not where the source file is so I was looking in the wrong place for the output

Thus this is the script the produced the desired results was...

$oExec = $WshShell->Run("C:\\Test\\ffmpeg -i C:\\Test\\ferrisglennnews.mov C:\\Test\\video.webm"); 

Thanks for those who helped out and who help out in forum period, you saved so many people soooo much time!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM