Run a .vbs from php

hi all,

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.

Any ideas???


Use PHP COM, everything that wshell can do, can be done via PHP’s COM object access!


/* 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 );
	echo 'can not create wshell object';

$obj = null;


Thanks for that printf

does this run on the webserver??? – as it going to be creating files on webserver

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.

cheers bigman

ive tried working with that but it keeps returning the

exception ‘com_exception’ with message ‘Source: Unknown
Description: Unknown’ in C:\Inetpub\wwwroot\virtual-directories\clearest\public\ppt\uploadppt.php:33 Stack trace: #0 C:\Inetpub\wwwroot\virtual-directories\clearest\public\ppt\uploadppt.php(33): com->Run(‘wscript.exe C:\…’, 0, false) #1 {main}

any ideas what…???

do you need to adjust the php.ini for this to work properly??