Schedule Windows Job with WMI
am 20.04.2007 22:00:02 von CMcDevitt------_=_NextPart_001_01C78386.7B97577C
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
I am trying to use WMI to schedule a Job. Here is the error and my code.
=20
Fatal error: Uncaught exception 'com_exception' with message
'Source: SWbemObjectEx
Description: Invalid parameter
' in
C:\Apache2.2\htdocs\com.php:46 Stack trace: #0
C:\Apache2.2\htdocs\com.php(46): variant->Create('"Cleanup.exe", ...')
#1 {main} thrown in
C:\Apache2.2\htdocs\com.php on line 46
=20
$hostname =3D ".";
$wmi =3D new COM("WinMgmts://{$hostname}/root/cimv2");
$JobId =3D "JobID";
$newJob =3D $wmi->Get("Win32_ScheduledJob");
$newJob->Create('"Cleanup.exe", "********123000.000000-420",True , 1 OR
4 OR 16, , , JobID');
=20
/*
VBScript That works:
strComputer =3D "."
Set objService =3D GetObject("winmgmts:\\" & strComputer)
Set objNewJob =3D objWMIService.Get("Win32_ScheduledJob")
errJobCreated =3D objNewJob.Create _
("Cleanup.exe", "********123000.000000-420", _
True , 1 OR 4 OR 16, , , JobID)=20
*/
=20
?>
------_=_NextPart_001_01C78386.7B97577C--