PPPersia Posted March 12, 2010 Posted March 12, 2010 Hi, I wanna delete all scheduled tasks that starts with a certain string, for example delete all scheduled tasks that their name start with "My Application Task". I need to do it via a VBScript code! I found a code but didn't test it: Dim SchedulesID As Integer Dim strComputer As String Dim objService As Object Dim objNewJob As Object SchedulesID = 1: strComputer = "." Set objService = GetObject("winmgmts:\\" & strComputer) If SchedulesID Then Set objInstance = objService.Get ("Win32_ScheduledJob.JobID=" & SchedulesID) objInstance.Delete End If But I don't know how to change it so delete by name? Anyone can help me do it since I am not very familiar with VBScript? Thank you :) Quote
Administrators PlausiblyDamp Posted March 13, 2010 Administrators Posted March 13, 2010 According to http://msdn.microsoft.com/en-us/library/aa394399%28VS.85%29.aspx it looks as the the Win32_ScheduledJob has a Name property, have you tried either searching on this or if that isn't possible you could loop over all jobs and compare the name property yourself. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.