Brian Webster Brian Webster - 1 year ago 92
PHP Question

How to run a .cmd file from within PHP and display the results

I need to run a .cmd batch file from within a php script.

The PHP will be accessed via an authenticated session within a browser.

When I run the .cmd file from the desktop of the server, it spits out some output to cmd.exe.

I'd like to route this output back to the php page.

Is this doable?

Answer Source

Yes it is doable. You can use

exec("mycommand.cmd", &$outputArray);

and print the content of the array:

echo implode("\n", $outputArray);

look here for more info

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download