Skip to content Skip to sidebar Skip to footer

Php Exec To Launch A Cmd Window With Parameters

I have been trying to launch a cmd window using the php exec method. The idea is to launch cmd and get it to start running a file. My first problem was being able to rewrite the ba

Solution 1:

Make sure the batch file is executable, then you can simply exec it:

exec('myscript.bat');

You shouldn't need to do it via cmd. If you want to for some reason, you will have to provide extra parameters just as you would on the command line:

exec('cmd /C myscript.bat');

http://ss64.com/nt/cmd.html

will show you how to provide other options to cmd (and explain the one above).

Have fun, let me know if you get any problems.

Post a Comment for "Php Exec To Launch A Cmd Window With Parameters"