View Single Post
Old 01-30-2013, 02:19 PM   PM User | #1
Raphael
New Coder

 
Join Date: Mar 2009
Posts: 70
Thanks: 3
Thanked 3 Times in 3 Posts
Raphael is an unknown quantity at this point
how to run .vbs from php

I've spent several hours searching and trying different things, but I can't get this script to run. It is called by a web page:


Code:
error_reporting(E_ALL);
ini_set('display_errors', '1');

if($_POST['store_list'] && $_POST['start_date'] && $_POST['end_date']){
$cmd = 'wscript.exe <path_to_script>/my_script.vbs /store_list:"' . urldecode($_POST['store_list']) . '" /start_date:"' . urldecode($_POST['start_date']) . '" /end_date:"' . urldecode($_POST['end_date']) . '"';

$ws = new COM('WScript.Shell');

$ws->Run('cmd /c ' . $cmd, 0, false);
}



I tried:
  • with & without wscript.exe, cscript.exe, cmd /c, cmd.exe /c, cmd.exe /c /k
  • referencing the path to the .vbs file with /, \, and \\
  • exec()
  • shell_exec()

When I run the script from the command line it works perfectly.

The .vbs file is in a path outside the wwwroot folder. I set the permissions on the .vbs file & the folder it's in to allow read & execute for the Internet Guest Account.

The web page seems to indicate the script is being executed but nothing happens. Process Explorer only shows the error: "[Error opening process]" but no other information.

Please help.
Raphael is offline   Reply With Quote