Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Create Make Scheduled Task Schedule.Service Daily Trigger Principal User Account ID Password SYSTEM Highest
Reference: http://msdn.microsoft.com/en-us/library/aa383614(VS.85).aspx
;script to create task _NULL = ObjectType( 'NULL', 0 ); ObjectType( 'BSTR', ObjectType( 'NULL', 0 ) ) userid = 'SYSTEM' password = _NULL ; A constant that specifies an executable action. ActionTypeExec = 0 ;******************************************************** ; Create the TaskService object. service = ObjectCreate("Schedule.Service") service.Connect() ;******************************************************** ; Get a folder to create a task definition in. rootFolder = service.GetFolder("\") ; The taskDefinition variable is the TaskDefinition object. ; The flags parameter is 0 because it is not supported. taskDefinition = service.NewTask(0) ;******************************************************** ; Define information about the task. ; Set the registration info for the task by ; creating the RegistrationInfo object. regInfo = taskDefinition.RegistrationInfo regInfo.Description = "Start NotePad without UAC prompt" regInfo.Author = "Administrator" ; Set the task setting info for the Task Scheduler by ; creating a TaskSettings object. settings = taskDefinition.Settings settings.Enabled = @TRUE settings.StartWhenAvailable = @TRUE settings.Hidden = @FALSE Principal = taskDefinition.Principal Principal.LogonType = 5; TASK_LOGON_SERVICE_ACCOUNT Indicates that a Local System, Local Service, or Network Service account is being used as a security context to run the task. Principal.RunLevel = 1; TASK_RUNLEVEL_HIGHEST ;******************************************************** ; Create the action for the task to execute. ; Add an action to the task to run notepad.exe. Action = taskDefinition.Actions.Create( ActionTypeExec ) Action.Path = "C:\Windows\System32\notepad.exe" ;*********************************************************** ; Register (create) the task. rootFolder.RegisterTaskDefinition( "RunNotePad", taskDefinition, 6, userid , password , 3) Pause(Principal.DisplayName , "Task submitted.") Exit
Article ID: W18200
Filename: Create Task Run as SYSTEM.txt
File Created: 2014:05:02:09:39:10
Last Updated: 2014:05:02:09:39:10