Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows Task Scheduler
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01023677
Message ID:
01023849
Views:
11
This message has been marked as a message which has helped to the initial question of the thread.
Here is an example of how to run a task in the task scheduler now, rather than waiting for it to hit the scheduled time:
ssfCONTROLS = 3  && Control Panel's Schedule Tasks folder
sJobName = 'fta'  && Name of the task to run
sRunVerb = 'R&un'  && Executing command
sEndVerb = '&End Task'  && Cancelling command
shellApp = Createobject('shell.application')
oControlPanel = shellApp.Namespace(ssfCONTROLS) && Schedule Tasks folder
oST = '
For Each folderitem In oControlPanel.items  && Loop though the items in the Control Panel items
    If folderitem.Name  = 'Scheduled Tasks'
        oST = folderitem.getfolder() && Found it
        Exit
    Endif
Next
If Vartype(oST) != 'O'
    Messagebox('Couldn't find 'TS' folder')
Endif
oJob = '
For Each folderitem In oST.items  && Loop through the different scheduled tasks until we fiind it.
    If   Lower(folderitem.Name)  = Lower(sJobName) 
        oJob = folderitem  && Found it
        Exit
    Endif
Next
If Vartype(oJob) !='O'
    Messagebox( 'Couldn't find ' + sJobName + ' item')
Else
    bEnabled = .T.
    oRunVerb = '
    oEndVerb = '
    s = 'Verbs: ' + Chr(13)
    For Each Verb In oJob.verbs  && Loop through the different commands in the scheduled task until we find right one.
        s = s + Chr(13) + Verb.Name
        If Verb.Name = sRunVerb
            oRunVerb = Verb
            bEnabled = .F.
        Endif
        If Verb.Name = sEndVerb
            oEndVerb = Verb
        Endif
    Next
    If bEnabled
        oJob.InvokeVerb(oEndVerb)  && Cancel the task
    Else
        Wait Window Nowait 'executing job'
        oJob.InvokeVerb(sRunVerb)  && Run the task!
    Endif
Endif
>Hi
>
>Can someone please tell me the class id (COM) name of the Windows task scheduler.
>
>Thanks in advance
>Geoff Scott
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform