Jump to content

sched


Recommended Posts

OK

can u create a scheduled task with autoIT?

AT creates SYSTEM account tasks with no access to anything

AT calling another program / script that uses RUNAS doesnt work - ACCESS DENIED

SCHtasks only available on XP not 2000

....

im lost

Hi,

this might be a very bad solution, but it should work. :)

#Include <Date.au3>

$runTime = "15.03.2006 00:43:30"

While 1
    Sleep (999)
    If _Now() = $runTime Then
        MsgBox(0,"", "That´s it")
    EndIf
WEnd

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

this might be a very bad solution, but it should work. :)

#Include <Date.au3>

$runTime = "15.03.2006 00:43:30"

While 1
    Sleep (999)
    If _Now() = $runTime Then
        MsgBox(0,"", "That´s it")
    EndIf
WEnd

So long,

Mega

i dont think that will work unless its been run in the startup folder

on a server that may not be logged in for example

Link to comment
Share on other sites

  • Moderators

Something like this should get you started:

; Install a custom error handler
$oMyError = ObjEvent('AutoIt.Error', 'MyErrFunc')

; Name of the command, batch program, or binary file and command line
; parameters that the schedule service uses to invoke the job.
$a_Command = "C:\Windows\System32\defrag.exe C: -f"

; Universal Time Coordinate (UTC) time to run a job.
$a_StartTime = "143000"; Specifies 14.30 (2:30 P.M.) in format HHMMSS.
$b_StartTime = "********" & $a_StartTime & ".000000-" & _
        RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation", _
        "ActiveTimeBias")

; If True, a scheduled job runs repeatedly on specific days.
$a_RunRepeatedly = True

; Used only when the RunRepeatedly parameter is True.
$a_DaysOfWeek = BitOR(1, 4, 16);This would run the task on Monday, Wednesday, and Friday.
; 1     Monday
; 2     Tuesday
; 4     Wednesday
; 8     Thursday
; 16    Friday
; 32    Saturday
; 64    Sunday

; Used only when the RunRepeatedly parameter is True.
$a_DaysOfMonth = 0
; 1             Day 1 of a month
; 2             Day 2 of a month
; 4             Day 3 of a month
; 8             Day 4 of a month
; 16            Day 5 of a month
; 32            Day 6 of a month
; 64            Day 7 of a month
; 128           Day 8 of a month
; 256           Day 9 of a month
; 512           Day 10 of a month
; 1024          Day 11 of a month
; 2048          Day 12 of a month
; 4096          Day 13 of a month
; 8192          Day 14 of a month
; 16364         Day 15 of a month
; 32768         Day 16 of a month
; 65536         Day 17 of a month
; 131072        Day 18 of a month
; 262144        Day 19 of a month
; 524288        Day 20 of a month
; 1048576       Day 21 of a month
; 2097152       Day 22 of a month
; 4194304       Day 23 of a month
; 8388608       Day 24 of a month
; 16777216      Day 25 of a month
; 33554432      Day 26 of a month
; 67108864      Day 27 of a month
; 134217728     Day 28 of a month
; 268435456     Day 29 of a month
; 536870912     Day 30 of a month
; 1073741824    Day 31 of a month

; If True, the specified job should be interactive, which means that
; a user can give input to a scheduled job while the job is executing.
$a_InteractWithDesktop = False
$strComputer = '.'
$JobID = ''
$objService = ObjGet('winmgmts:\\' & $strComputer)
If Not IsObj($objService) Or @error Then
    MsgBox(0, @ScriptName, 'No Object!', 5)
    Exit
EndIf
$objNewJob = $objService.Get ('Win32_ScheduledJob')
$errJobCreated = $objNewJob.Create _
        ($a_Command, $b_StartTime, _
        $a_RunRepeatedly, $a_DaysOfWeek, $a_DaysOfMonth, $a_InteractWithDesktop, $JobID)
If $errJobCreated = 0 And Not @error Then
    MsgBox(262144, @ScriptName, 'Job successfully created.' & @LF & 'New Job ID: ' & $JobID, 10)
Else
    MsgBox(4096, @ScriptName, 'An error has occurred!' & @LF & 'Error code :' & $errJobCreated, 10)
EndIf
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & $HexNumber & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
    ClipPut('COM Error: ' & $HexNumber & @CRLF & 'Description: ' & $oMyError.windescription)
    SetError(1); something to check for when this function returns
EndFunc  ;==>MyErrFunc

Edit: Script now pulls current time zone bias from the registry.

Edit: Made it easier to specify start time.

Edited by big_daddy
Link to comment
Share on other sites

Just wanted to add that a scheduler sometimes should run as a service so the user does not have to be logged on.

I have used (using) xyntservice. The download-able zip did contain a binary when I first encountered it.

I have not tried it but there apparently is a GUI to it.

But then again you could use the task scheduler service, if it is running.

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...