Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 :)

  • Administrators
Posted
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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...