I have created a script to run a task on task scheduler, which can open notepad program.
I imported the task with this code:
Code: Select all
run, schtasks /create /tn "Open Notepad" /xml "C:\Users\%user%\Downloads\A\Open Notepad.xml" /ru %computer_name%\username /rp password
But I tried to enable it using this code:
Code: Select all
!v:: ; Enable Task:
TaskEnabled("Test", "\", True)
return
!e:: ; Disable Task:
TaskEnabled("Test", "\", False)
return
; TaskName: Name of the Task.
; TaskFolder: Folder where the Task is located.
; Enabled: 'True' to enable Task or 'False' to disable it.
TaskEnabled(TaskName, TaskFolder="\", Enabled=True)
{
Service := ComObjCreate("Schedule.Service")
Service.Connect()
Service.GetFolder(TaskFolder).GetTask(TaskName).Enabled := Enabled
}
I tried to replace "TaskName" and "TaskFolder" with the exact task name and its path to tasks folder inside System32, also the same dialogue box appeared.
Hope someone can help me.
Thanks in advance.