Schedule Windows Job with WMI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to use WMI to schedule a Job. Here is the error and my code.
 
Fatal error: Uncaught exception 'com_exception' with message
'<b>Source:</b> SWbemObjectEx<br/><b>Description:</b> 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
 
<?php 
$hostname = ".";
$wmi = new COM("WinMgmts://{$hostname}/root/cimv2");
$JobId = "JobID";
$newJob = $wmi->Get("Win32_ScheduledJob");
$newJob->Create('"Cleanup.exe", "********123000.000000-420",True , 1 OR
4 OR 16, , , JobID');
 

/*
VBScript That works:
strComputer = "."
Set objService = GetObject("winmgmts:\\" & strComputer)
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
    ("Cleanup.exe", "********123000.000000-420", _
        True , 1 OR 4 OR 16, , , JobID) 
*/
 
?>

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux