Jump to content

Scheduled Task Help


Recommended Posts

Hi, I am attempting to create a scheduled task on multiple systems using a script. The task needs to run 2 minutes from the current time on the computer, regaurdless of if the time is correct or not. This will need to run on XP, Vista, 7 and Windows 8.

I have figured out windows Vista, 7 and 8, but it seems like XP needs a bit more. Below is a script I have been testing, it will run through the script, and I have it make a string, which I then run, but does not make the task. I have it output to a MsgBox, and it seems like the string for the command is correct.

Anyone have any ideas?

$h = @HOUR
   $m = @MIN
   $m = $m + 5
   If $m == 60 Then
      $m = "00"
      $h = $h + 1
   ElseIf $m == 61 Then
      $m = "01"
      $h = $h + 1
   ElseIf $m == 62 Then
      $m = "02"
      $h = $h + 1
   ElseIf $m == 63 Then
      $m = "03"
      $h = $h + 1
   ElseIf $m == 64 Then
      $m = "04"
      $h = $h + 1
   ElseIf $m == 65 Then
      $m = "05"
      $h = $h + 1
   Else
      $m = $m
   EndIf 
   Run("SchTasks /Delete /TN /f 'DHCDScript'")
   $scTas = "schtasks /create /sc minute /mo 5 /tn DHCDScript /tr '" & $sFldr1 & "\clean2.exe' /st " & $h & ":" & $m & ":00 /p '" & $unpass & "'" ;/u '" & @ComputerName & "\" & @UserName & "'"
   Run($scTas)
Link to comment
Share on other sites

I'm no longer on XP, so I can't help you with your schtask code. At a glance, it looks right.

I will offer this to help simply your adding minutes and adjusting the hour:

$h = @HOUR
$m = @MIN

If $m > 54 AND $m < 60 Then
    $h += 1
    $m -= 55
Else
    $m += 5
EndIf

MsgBox(0, "", "Minute: " & $m & @CRLF & "Hour: " & $h)
Edited by abberration
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...