|
|
|
| 24 February 2003 | atNewJob() |
| Author | Florian Lagg, ICQ 167357108 |
| Action | Adds a scheduled Jobs on a specific host. |
| Syntax | atNewJob ($sComputer, $sCommand, $tStart, $bRepeat, $iDaysOfWeek, $iDaysOfMonth, $bInteractive) |
| Parameters | |
| Remarks | $tStart: Starttime of the job in following format: "********133000.000000+060" = 13:30 MEZ (Winter time, normal time) "********133000.000000+000" = 13:30 MEZ (Summer time, daylight saving time) $iDaysOfMonth: Joined (2^(days_of_a_month-1)) e.g.: the first and the fifth of any month (uses function EXP out of this lib EXP(2,1-1) | EXP(2,5-1) |
| Returns | -1 = error: WMI probably not installed or -2 = error: WMI query for scheduled job failed or -4 = error: insert Job failed |
| Dependencies | WMI |
| Examples |
$err = atNewJob ("", "notepad.exe", "********133000.000000+060", false, 0, 0, true)
|
| Source |
FUNCTION atNewJob ($scomputer, $scommand, $tstart, $brepeat, $idaysofweek, $idaysofmonth, $binteractive)
IF ($scomputer = "")
$scomputer = "." ; (=localhost)
ENDIF
$objwmiservice = GetObject("winmgmts:"+"{impersonationLevel=impersonate}!\\"+$scomputer+"\root\cimv2")
IF @error = 0
$objinstance = $objwmiservice.get("Win32_ScheduledJob")
IF @error = 0
$err = $objinstance.create($scommand, $tstart, $brepeat , $idaysofweek, $idaysofmonth, $binteractive, $jobid)
IF $err <> 0
$atnewjob = -4
ENDIF
ELSE
$atnewjob = -2
ENDIF
ELSE
$atnewjob = -1
ENDIF
$objwmiservice = 0
ENDFUNCTION ; - atNewJob -
|
|
|
|