[RESOLVED] WScript.Shell suddenly stopped working (Win32)
This is more of a Windows OS problem than a PHP, even if I'm using PHP for it lol.
I don't know why this error is suddenly happening, as it was working fine.
Quote:
Originally Posted by error
Warning: (null)(): Invoke() failed: Exception occurred. Source: Unavailable Description: Unavailable in c:\webserver\htdocs\includes\functions.php on line 47
This is the offending lines (PHP of course):
Quote:
// Make a new instance of the COM object
$WshShell = new COM("WScript.Shell");
// Make the command window but don't show it.
$oExec = $WshShell->Run($cmdline, 0, true); << line 47
This is really annoying me.... Any Ideas?
Or advise me another way to execute external programs in PHP, that returns either a false or true........
TIA
Re: WScript.Shell suddenly stopped working (Win32)
ok, I think I found out why.... a CMD.EXE was stuck in the process list, it wouldn't break/end, so I had to reboot PC..... Will get back after further tests........
Ha! Technology....don't you just love it?
Re: WScript.Shell suddenly stopped working (Win32)
Ok, this didnt sove it....... So, has anyone any exampl,es of another way of using CMD or executing an .exe with args.........oh on a Win2000 machine before I forget....... :)
TIA
Re: WScript.Shell suddenly stopped working (Win32)
I need to see more of that functions.php file. Specifically the Run() function.
Also, if you can, post the shell script. I'll see if i can find out the problem from there.
Re: WScript.Shell suddenly stopped working (Win32)
Quote:
Originally Posted by Triumph
I need to see more of that functions.php file. Specifically the Run() function.
Also, if you can, post the shell script. I'll see if i can find out the problem from there.
Ok, heres a snippet....... It was working before I originally posted my query.. Maybe MS disabled the COM object in an update?
Code:
<?
require_once("c:/webserver/htdocs/includes/dbasefunctions.php");
function AddUser($account_type) {
global $account_type,$firstname,$lastname,$sex,$country,$accountname,$email,$password,$password1,$password2,$secretquestion,$secretanswer,$date_day,$date_month,$date_year,$post_code,$alt_email,$paid,$ip;
//
// Get a good ol' timestamp. Unique and it works.
$unixtime = time();
// Sets up your exe or other path.
$cmd = 'C:\\Program Files\\Merak\\users.exe';
// Setup an array of arguments to be sent.
$arg[] = "-a";
$arg[] = "-u".$email."@<hidden>.co.uk";
$arg[] = "-n".$firstname."_".$lastname;
$arg[] = "-p".$password1;
$arg[] = "-m".$email;
//
if ($account_type == "free") {
$arg[] = "-i+20000";
$arg[] = "-k10000";
$arg[] = "-4-";
$arg[] = "-z-";
$arg[] = "-s-";
$arg[] = "-x-";
$arg[] = "-j-";
$query = "update users set U_ServicesAccess=206 where U_Mailbox=\"$email\"";
} elseif ($account_type == "premium") {
$arg[] = "-i+250000";
$arg[] = "-k0";
$arg[] = "-4-";
$arg[] = "-z-";
$arg[] = "-s-";
$arg[] = "-x-";
$arg[] = "-j-";
$query = "update users set U_ServicesAccess=200 where U_Mailbox=\"$email\"";
}
//$arg[] = "-cfg\"C:\Program Files\Merak\\"";
// Pick a place for the temp_file to be placed.
$outputfile = 'C:\\unixtime.txt';
// Setup the command to run from "run"
$cmdline = "cmd /C \"$cmd\" " . implode(' ', $arg) . " >$outputfile";
//$cmdline2 = "\"$cmd\" > $outputfile";
// Make a new instance of the COM object
$WshShell = new COM("WScript.Shell");
// Make the command window but don't show it.
$oExec = $WshShell->Run($cmdline,0,true);
// Read the file file.
$output = file($outputfile);
// Delete the temp_file.
//unlink($outputfile);
if($oExec=="0") {
blah bl.ah
?>
Thanks
Re: [RESOLVED] WScript.Shell suddenly stopped working (Win32)
Re: [RESOLVED] WScript.Shell suddenly stopped working (Win32)
Just out of curiosity, what was the problem?