scripting@wanadoo.nl




atNewJob()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
24 February 2003 atNewJob()
AuthorFlorian Lagg, ICQ 167357108
Action Adds a scheduled Jobs on a specific host.
SyntaxatNewJob ($sComputer, $sCommand, $tStart, $bRepeat, $iDaysOfWeek, $iDaysOfMonth, $bInteractive) 
Parameters
  • $sComputer (Required / String) Hostname of remote Computer or "" for localhost
  • $sCommand (Required / String) command to execute
  • $tStart (Required / String) Starttime of the job (Format see remarks)
  • $bRepeat (Required / Boolean) should the process run repeatedly on scheduled days?
  • $iDaysOfWeek (Required / Numeric) Joined weekdays, e.g.: ($atMonday | $atWednesday)
  • $iDaysOfMonth (Required / Numeric) see remarks
  • $bInteractive (Required / Boolean) Start as interactive Process 
  • 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 
    DependenciesWMI 
    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 -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter