How to add a button that runs an application with php?

3

How do I create a button to run an application on my server through php? What I want is through a webpage I can execute a script or application (* .vbs, * .exe) on my server.

    
asked by anonymous 18.04.2018 / 04:38

1 answer

2

There are several ways to run a program through php. However, if the server is not enabled, not the entire program can be run.

Option 1 - Using exec ()

With this command it will execute the program and return the last line of the result.

$retorno = exec('wscript "dir/arquivo.vbs"');

Option 2 - Using COM

Using COM might be interesting if you are running windows programs. He is fit for it. You can run word programs for example.

$obj = new COM ( 'WScript.Shell' );
$obj->Run ( 'cmd /C ' . "wscript.exe dir/arquivo.vbs", 0, FALSE );

Option 3 - Using the shell_exec shell_exec

shell_exec is very similar to exec , however it will execute a program via shell and will return all its output.

$retorno = shell_exec (start wscript "dir/arquivo.vbs");

Option 4 - Using the system

It also looks like exec , but it returns the result on the screen to the user if a variable is not assigned to the command.

system("dir/arquivo.vbs");
    
18.04.2018 / 08:36