Jump to content

Recommended Posts

Posted

I'm trying to edit scheduled tasks through the COM object, but somehow it seems to be a little stubborn when i'm doing anything other than just reading.

$TaskRootFolder = "\myFolder"
$oTaskSchedule = ObjCreate("Schedule.Service")
$oTaskSchedule.connect()
$oRootFolder = $oTaskSchedule.GetFolder($TaskRootFolder)
If IsObj($oRootFolder) then
    $oTaskDefinition = $oRootFolder.GetTasks(0)
    $NumTasks = $oTaskDefinition.count
    ConsoleWrite($NumTasks & " tasks found in " & $TaskRootFolder & @CRLF)
    For $oTask in $oTaskDefinition
        ConsoleWrite("Task: " & $oTask.name & " enabled: " & $oTask.enabled & @LF)
        $oTask.enabled = False
    Next

Else
    ConsoleWrite("Task scheduler rootfolder not found." & @LF)
    Exit
EndIf

In the above code i connect just fine to the object, and i can read the tasks just fine. But nothing happens when i try to modify it with " $oTask.enabled = False ". I have tried every possible syntax of this i could think of but nothing works. Any info or ideas would be greatly appreciated.

Posted

Bitten, Your code works for me on Windows 7. I have tested with $TaskRootFolder = "". I can disable and enable all tasks with your code. Are you sure you have the necessary rights to modify the tasks?

Posted

Bitten, Your code works for me on Windows 7. I have tested with $TaskRootFolder = "". I can disable and enable all tasks with your code. Are you sure you have the necessary rights to modify the tasks?

 

Hmm, strange, it's not working on my own windows 7, however i'm part of a domain, so it may be a rights problem. I am a local administrator of my windows system though, and running it as an admin makes no difference.

Posted

I have tested on a standalone PC. Have you tried to fill in the parameters of the Connect method?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...