#43505 - 2003-07-29 07:08 AM
task scheduler help
|
rbardo
Fresh Scripter
Registered: 2003-07-24
Posts: 47
Loc: USA
|
Hey guys, me again.. Please tell me if I correctly inserted the parameters. It was a little confusing to me on how exactly I should apply the info. Thanks.
code:
;=============================================================================================== ;**** Created with KiXscripts Editor | http://KiXscripts.com **** ;**** Last Modified on 7/28/2003 at 10:10:42 PM by R1 **** ;===============================================================================================
;FUNCTION ScheduleTask ; ;ACTION Schedules a task on any computer using the Task Scheduler ; ;AUTHOR Jens Meyer (sealeopard@usa.net) ; ;VERSION 1.2 (removed error code trigger for deleting non-existing tasks, changed order of ; parameters that create task, updated header with regards to quote usage, added ; optional typearguments) ; 1.1 (added error codes, streamlined code) ; 1.0 ; ;DATE CREATED 2001/12/04 ; ;DATE MODIFIED 2003/06/28 ; ;KIXTART 4.12+ ; ;SYNTAX SCHEDULETASK($NAME,$COMP,$DATE,$TIME,$TYPE,$USER,$PW,$COMMENT,$COMMAND [,$PARAMETERS, TYPEARGS]) ; ;PARAMETERS NAME ; name of the task ; ; COMP ; computername on which the task is to be run, computer must have the Task Scheduler installed ; ; DATE ; date on which to run the task (M/D/Y or TODAY) ; ; TIME ; time on which to run the task (H:M or NOW) with NOW indicating 60 seconds in the future ; ; TYPE ; trigger types (DAILY n | WEEKLY n, | MONTHLYDATE , | MONTHLYDOW n,,months | ; ONCE | ONIDLE | ATSTARTUP | ATLOGON) ; ; USER ; userid under which to run the task (can be any valid local or domain user) ; ; PW ; password for the userid ; ; COMMENT ; comment field with information about task, cannot contain the quote character " ; ; COMMAND ; the command to be executed by the task scheduler, cannot contain the quote character " ; ; PARAMETERS ; optional parameters that are provided to the command, cannot contain the quote character " ; ; TYPEARGS ; Optional parameter for trigger types, see jt /? ctj for details ; ;RETURNS 0 if successful, otherwise error code ; ;REMARKS Requires the file JT.EXE, which is part of the Microsoft Windows 2000 Resource Kit Supplement ; and can be downloaded at ftp://ftp.microsoft.com/reskit/win2000/jt.zip ; Best used to schedule batch files due to problems with double quote usage in soem of the JT.EXE parameters. ; ;DEPENDENCIES none ; ;EXAMPLE $name='demo.job' ; $comp='SERVER' ; $date='11/11/01' ; $time='NOW' ; $type='ONCE' ; $user='administrator' ; $pw='adminpassword' ; $comment='cool!' ; $command='notepad' ; $parameters='' ; $typeargs='' ; $retcode=scheduletask($name,$comp,$date,$time,$type,$user,$pw,$comment,$command,$parameters, $typeargs) ; ;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000060 ; Function scheduletask($name, $comp, $date, $time, $type, $user, $pw, $comment, $command, optional $parameters, optional $typeargs) Dim $jtexe, $shellcmd, $retcode
If $name='servicepackupdate' OR $comp= @WKSTA OR $date='Today' OR $time='1:00' OR $type='Monthly' Exit 87 EndIf If $user='blue\administrator' OR $pw='password' OR $comment='Lets do This!'OR $command= @lserver+ '\netlogon\Wkix.exe /i servicepackupdate.kix' Exit 87 EndIf If NOT VarType($parameters) Dim $parameters $parameters='' EndIf
; this should point to your copy of jt.exe $jtexe= @LSERVER+ 'netlogon\progs\jt.exe' If NOT Exist($jtexe) Exit 2 EndIf
; delete a potentially existing task $shellcmd = $jtexe $shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"' $shellcmd = $shellcmd+ ' /SM \\'+$comp $shellcmd = $shellcmd+ ' /SD "'+$name+'"'
Shell '%COMSPEC% /e:1024 /c '+$shellcmd
$shellcmd = $jtexe
$shellcmd = $shellcmd+ ' /SAJ '+$name
$shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"'
$shellcmd = $shellcmd+ ' /SM \\'+$comp
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$command+'"' $shellcmd = $shellcmd+ ' Parameters="'+$parameters+'"' $shellcmd = $shellcmd+ ' WorkingDirectory="%SYSTEMROOT%"' $shellcmd = $shellcmd+ ' Comment="'+$comment+'"' $shellcmd = $shellcmd+ ' Creator="'+@user+'"' $shellcmd = $shellcmd+ ' Priority=Normal' $shellcmd = $shellcmd+ ' MaxRunTime=3600000' $shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0' $shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0' $shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0' $shellcmd = $shellcmd+ ' SystemRequired=0' $shellcmd = $shellcmd+ ' DeleteWhenDone=1' $shellcmd = $shellcmd+ ' Suspend=0' $shellcmd = $shellcmd+ ' StartOnlyIfIdle=0' $shellcmd = $shellcmd+ ' KillOnIdleEnd=0' $shellcmd = $shellcmd+ ' RestartOnIdleResume=0' $shellcmd = $shellcmd+ ' Hidden=0' $shellcmd = $shellcmd+ ' TaskFlags=0'
$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date $shellcmd = $shellcmd+ ' StartTime='+$time $shellcmd = $shellcmd+ ' HasEndDate=0' $shellcmd = $shellcmd+ ' KillAtDuration=0' $shellcmd = $shellcmd+ ' Disabled=0' $shellcmd = $shellcmd+ ' Type='+$type $hsellcmd = $shellcmd+ ' TypeArguments='+$typeargs
Shell '%COMSPEC% /e:1024 /c '+$shellcmd $scheduletask=@ERROR Exit @ERROR EndFunction
[ 29. July 2003, 07:09: Message edited by: rbardo ]
_________________________
Ekadanta Mahakaya Surya koti samaprabha
Nirbighnam kurume deva sarbakaryeshu sarbada
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 339 anonymous users online.
|
|
|