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

Asked

Viewed 248 times

3

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.

1 answer

2


There are several ways to run a program by php. However, if the server is not enabled, the whole program cannot 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 the WITH

Use the COM can be interesting if you are running windows programs. It is proper for this. 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

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

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

Option 4 - Using the system

It also looks like the 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");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.