i have vbscript (.vbs) file that i need to run from a php webpage. But how do i call and run the .vbs file???
i need to pass variables to the script as it initiates. Locally i use wshell or a windows shortcut to run the file but am stuck how to call and run it from php and i dont really wanna use .asp.
Use PHP COM, everything that wshell can do, can be done via PHP’s COM object access!
<?php
/* command to run */
$command = 'wscript.exe C:/path_to/vbs_file.vbs argument_one argument_two';
/*
* wait for command to return a exit code?
*
* true = waits for the command to complete, before continuing this script
* false = executes command then continues this script without waiting for command to exit
*
*/
$wait = false;
// run it
$obj = new COM ( 'WScript.Shell' );
if ( is_object ( $obj ) )
{
$obj->Run ( 'cmd /C ' . $command, 0, $wait );
}
else
{
echo 'can not create wshell object';
}
$obj = null;
?>
Yes, if the server is on a windows box that includes (IIS, Apache, Sambar, Sun ONE, Netscape, Merak) and few other, I don’t remember all of them, but if PHP can run on the server, then local COM access via PHP will be available too! Remote access is also available if DCOM is active for that object. Java Also has a DCOM connector for Linux that allows you to run remote or local non-registry binding COM objects in PHP, under Linux too.