TaskScheduler: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
mNo edit summary
Line 6: Line 6:


[[File:Task Scheduler Object Model.png||Task Scheduler Object Model]]
[[File:Task Scheduler Object Model.png||Task Scheduler Object Model]]
Details can be found here:
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/taskservice TaskService]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/taskfoldercollection Folders]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/taskfolder Folder]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/registeredtaskcollection RegisteredTasks]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/runningtaskcollection RunningTasks]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/registeredtask RegisteredTask]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/taskdefinition TaskDefinition]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/registrationinfo RegistrationInfo]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/settings Settings]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/idlesettings IdleSettings]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/networksettings NetworkSettings]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/principal Principal]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/triggercollection Triggers]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/trigger Trigger]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/tasknamedvaluecollection NamedValues]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/tasknamedvaluepair NamedValuePair]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/repetitionpattern RepetitionPattern]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/actioncollection Actions]
* [https://docs.microsoft.com/de-de/windows/win32/taskschd/action Action]


= How to create a task =
= How to create a task =

Revision as of 19:22, 14 September 2019

This page is still a work in progress.

The TaskScheduler UDF offers functions to control and manipulate the Windows Task Scheduler.

Structure

The UDF uses the Windows Task Scheduler Object Model

Task Scheduler Object Model

Details can be found here:

How to create a task

There's more than one way to skin a cat - I mean: to create a task. This list is sorted from easy to hard:

  1. Use the Task Scheduler GUI and create the task ;-)
  2. Use the wrapper functions provided by the UDF
  3. Use a template task and export it to a file. Modify the XML source and import it using the Task Scheduler GUI
  4. Export the XML source from an existing task using _TS_TaskExportXML to memory or to a file, modify this XML source and create a new task using _TS_TaskImportXML
  5. Retrieve the properties of an existing task to memory, modify the properties and create the new task by using _TS_TaskCreate, _TS_TaskPropertiesSet and _TS_TaskRegister
  6. Retrieve the properties of an existing task as AutoIt array code, copy the array from the console to your script, modify the properties and create a new task using _TS_TaskCreate, _TS_TaskPropertiesSet and _TS_TaskRegister

Functions

_TS_Open

Connects to the Task Scheduler Service and additionally allows to control and manipulate the Task Scheduler on another computer.

You must ensure the following before you begin (more details can be found here):

  • Your computer and the remote computer must be part of a domain or a Workgroup
  • You must know the IP Address of the remote computer
  • You must have the login credentials for the remote computer and the login credential must be part of the Administrators group on the remote computer
  • You may want to ensure that your Firewall allows “Remote Scheduled Tasks Management”


Examples how to connect to another computer (thanks to AdamUL for testing):

; Connect to a computer in AD where the current user is in a the local Admininstrators group 
; on that computer, via domain or local group, or directly. Use AD computer name.
Global $oService = _TS_Open("COMPUTERNAME")

; Connect to a computer in AD where the entered user (AdminUser) is an AD user, and is in the 
; local Administrators group on that computer, via domain or local group, or directly. Use AD computer name.
Global $oService = _TS_Open("COMPUTERNAME", "AdminUser", "AD", "Password") 

; Connect to a computer in AD where the entered local user (Administrator) is NOT an AD user, 
; and is in the local Administrators group on that computer, via local group, or directly. Use AD computer name.
Global $oService = _TS_Open("COMPUTERNAME", "Administrator", ".", "Password") 

; Non-domain computer where the entered local user (Administrator) is in the local Administrators group 
; on that computer. Use IP address or DNS name to connect.
Global $oService = _TS_Open("192.168.0.1", "Administrator", ".", "Password")

Debugging connection problems

At the end of this github page you will find a tool named "Task Scheduler Configuration Troubleshooter". It analyzes possible connection problems and tells you what to do or even tries to solve the problem.