How do I create a button to run an application on my server through php? What I want is through a web page I can run a script or application (*.vbs, *.exe ) on my server.
There are several ways to run a program through php. However, if the server is not enabled, not the entire program will be able to run.
Option 1 – Using exec()
With this command it will run the program and return the last line of the result.
$retorno = exec('wscript "dir/arquivo.vbs"');
Option 2 – Using COM
COM can be interesting if you are going to run windows programs. He's fit for it. You can run programs in word for example.
$obj = new COM ( 'WScript.Shell' ); $obj->Run ( 'cmd /C ' . "wscript.exe dir/arquivo.vbs", 0, FALSE );
Option 3 – Using shell_exec
shell_exec is very similar to
exec , but it will execute a program via the shell and return all its output.
$retorno = shell_exec (start wscript "dir/arquivo.vbs");
Option 4 – Using the system
It is also similar to
exec , but it returns the result on the screen to the user if a variable is not assigned to the command.