Avatar of bsharath
bsharath
Flag for India asked on

Find if every machine in the txt file has a scheduled task called "Infected scan'.

Hi,

Find if every machine in the txt file has a scheduled task called "Infected scan'.
Record the success and failure in a txt file.
Permission error
timed out
Scheduled scan available
Scheduled scan not available

Regards
Sharath
Programming Languages-OtherWindows BatchVB Script

Avatar of undefined
Last Comment
bsharath

8/22/2022 - Mon
sirbounty

What OS?  Presumably these were scheduled with schtasks, not at scheduler?
bsharath

ASKER
Hi Sirbounty.

Os is windows 2000,Xp & Windows 2003 all these have to be queried...
bsharath

ASKER
Hi Sirbounty.

Os is windows 2000,Xp & Windows 2003 all these have to be queried...
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Krys_K

Hi Sharath
See how you get on with this. Its using the command line tool called SchTask which will only look for a scheduled task and not an AT task.
If you need AT tasks the i have a script for that too, it'll just need tweaking for your needs.
See how you get on
Regards
Krystian
P.S. The only things you should need to change are the File names and locations near the top and 1 place in teh EnumSchedTask sub which has a WScript.Sleep. This is currently set to 1 second but you may want to decrease or increase depending on how it performs. If its taking too long then decrease it or if its not catching results then increase it, though i suspect the latter is unlikely.

Option Explicit
 
 
' Global Variables
	Dim gsOutput, gsHeader
 
	Call ReadWriteFile
	
Sub ReadWriteFile()
' Version 1.0
 
' Declare Variables
 	Dim fso, oFile
	Dim arrComputers
	Dim sReadResults
	Dim i
 
' fso Constants
	Const ForReading = 1                              'Used for file open
	Const ForWriting = 2                              'Used for file open
	Const ForAppending = 8                            'Used for file open
 
' User Defined constants
	Const sFileLocation = "C:\ComputerList.txt" 	  '<_______Change to suit
	Const sSaveFile = "C:\SchedTasksReport.csv"		  '<_______Change to suit
 
' Set the Header
	gsHeader = "HostName,TaskName,NextRunTime,Status"
	
' Create Objects
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set oFile = fso.OpenTextFile(sFileLocation, ForReading, False)
	
		If Err.Number <> 0 Then
			WScript.Echo "Error reading File " & sfileLocation
			Exit Sub
		End If
	
' Read the whole contents of the File
	Do While oFile.AtEndOfStream <> True
		sReadResults = oFile.ReadAll
	Loop
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
 
' Create an array of computers
	arrComputers = Split(sReadResults, vbNewLine)
	
' Loop each computer
	For i = 0 to Ubound(arrComputers)
		If arrComputers(i) = "" Then 
			Exit For
		End If 
	
			If Reachable(arrComputers(i)) = True Then
				ShowProgress arrComputers(i)
				Call EnumSchedTasks(arrComputers(i))
			Else
				ShowProgress arrComputers(i) & " Unreachable"
				gsOutput = gsOutput & arrComputers(i) & ",Unreachable" & vbNewLine
			End If
		
	Next ' i	
 
' Write or append the results
	If Not fso.FileExists(sSaveFile) Then
		Set oFile = fso.OpenTextFile(sSaveFile, ForWriting, True)
			If Err.Number <> 0 Then
				ShowProgress "Error creating file " & sSaveFile
				Exit Sub
			End If
		
		ofile.Write(gsHeader & gsOutput)
	Else
		Set oFile = fso.OpenTextFile(sSaveFile, ForAppending, False)
			If Err.Number <> 0 Then
				ShowProgress "Error opening file " & sSaveFile
				Exit Sub
			End If
 
		ofile.Write(gsOutput)
	End If 
 
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
	
 
End Sub ' ReadWriteFile
 
 
Sub EnumSchedTasks(sArgComputer)
' Version 1.0
' Writen by Krystian Karia
' Dated 16/03/2009
 
' Runs the SchTasks.exe tool to query remote shceduled tasks
' on the computers passed to us and log to a global variable
 
' Catch errors ourselves
'	On Error Resume Next
 
' Declare the local variables
	Dim WshShell, objCmdExec
	Dim strCmdTool, strCmdArgs1, strCmdArgs2
	Dim strOutput, iQuit
 
	Const Exec_Running = 0
	Const Exec_Finished = 1
 
' Create Objects
	Set WshShell = CreateObject("Wscript.Shell")
 
 
' Set the command line arguments to work with
	strCmdTool = "schtasks.exe"			' Full path and filename of cmd line tool
	strCmdArgs1 = " /Query /S "			' Cmd line arguments
	strCmdArgs2 = " /FO CSV /NH "		' Cmd line arguments
 
' Run the commandline tool and get the output
	Set objCmdExec = WshShell.Exec(strCmdTool & strCmdArgs1 & sArgComputer & strCmdArgs2)
 
		iQuit = 1
		Do Until (objCmdExec.Status <> Exec_Running Or iQuit = 10)
			WScript.Sleep 1000		'<___ Increase or decrease if required (1000 = 1 Second)
			iQuit = iQuit + 1
		Loop 
		
		If iQuit = 10 Then
		'Terminate if it takes too long
			ShowProgress "Terminating"
			objCmdExec.Terminate
		End If
 
			strOutput = strOutput & objCmdExec.StdOut.ReadAll
 
				If (Err.Number <> 0) Or strOutput = "" Then
					ShowProgress "An Error occurred. Try running manually (in Cmd) to host to see the problem"
					gsOutput = gsOutput & sArgComputer & ",An Error Occured Running " & strCmdTool & vbNewLine
					Err.Clear
				End If
 
		If Trim(strOutput) <> "" Then
			If InStr(UCase(Replace(strOutput, vbNewLine, "")), "INFECTED SCAN") > 0 Then 
				ShowProgress "TaskName: " & Replace(Left(strOutput, InStr(strOutput, ",") -1), vbNewLine, "") & vbNewLine
			
				gsOutput = gsOutput & sArgComputer & "," & Replace(strOutput, vbNewLine, "") & vbNewLine
				strOutput = ""
			End If 
		End If
 
 
End Sub ' EnumSchedTasks
 
Private Function Reachable(strComputer)
' Version 1.0
 
     On Error Resume Next
 
    Dim wmiQuery, objWMIService, objPing, objStatus
    
    wmiQuery = "Select * From Win32_PingStatus Where " & _
    	"Address = '" & strComputer & "'"
    
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery(wmiQuery)
    
    For Each objStatus in objPing
        If IsNull(objStatus.StatusCode) Or objStatus.Statuscode <> 0 Then
            Reachable = False 'if computer is unreacable, return false
        Else
            Reachable = True 'if computer is reachable, return True
        End If
    Next
End Function ' Reachable
 
Private Sub ShowProgress(sComment)
 
	WScript.Echo sComment
 
End Sub

Open in new window

Krys_K

Hi Sharath
Here is one for the AT Jobs incase it's them instead.
Regards
Krystian
P.S. script is almost the same, so amend the paths as you may have done before.

Option Explicit
 
 
' Global Variables
	Dim gsOutput, gsHeader
 
	Call ReadWriteFile
	
Sub ReadWriteFile()
' Version 1.0
 
' Declare Variables
 	Dim fso, oFile
	Dim arrComputers
	Dim sReadResults
	Dim i
 
' fso Constants
	Const ForReading = 1                              'Used for file open
	Const ForWriting = 2                              'Used for file open
	Const ForAppending = 8                            'Used for file open
 
' User Defined constants
	Const sFileLocation = "C:\ComputerList.txt" 	  '<_______Change to suit
	Const sSaveFile = "C:\SchedTasksReport.csv"		  '<_______Change to suit
 
' Set the Header
	gsHeader = "HostName,TaskName"
	
' Create Objects
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set oFile = fso.OpenTextFile(sFileLocation, ForReading, False)
	
		If Err.Number <> 0 Then
			WScript.Echo "Error reading File " & sfileLocation
			Exit Sub
		End If
	
' Read the whole contents of the File
	Do While oFile.AtEndOfStream <> True
		sReadResults = oFile.ReadAll
	Loop
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
 
' Create an array of computers
	arrComputers = Split(sReadResults, vbNewLine)
	
' Loop each computer
	For i = 0 to Ubound(arrComputers)
		If arrComputers(i) = "" Then 
			Exit For
		End If 
	
			If Reachable(arrComputers(i)) = True Then
				ShowProgress arrComputers(i)
				Call EnumATJobs(arrComputers(i))
			Else
				ShowProgress arrComputers(i) & " Unreachable"
				gsOutput = gsOutput & arrComputers(i) & ",Unreachable" & vbNewLine
			End If
		
	Next ' i	
 
' Write or append the results
	If Not fso.FileExists(sSaveFile) Then
		Set oFile = fso.OpenTextFile(sSaveFile, ForWriting, True)
			If Err.Number <> 0 Then
				ShowProgress "Error creating file " & sSaveFile
				Exit Sub
			End If
		
		ofile.Write(gsHeader & gsOutput)
	Else
		Set oFile = fso.OpenTextFile(sSaveFile, ForAppending, False)
			If Err.Number <> 0 Then
				ShowProgress "Error opening file " & sSaveFile
				Exit Sub
			End If
 
		ofile.Write(gsOutput)
	End If 
 
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
	
 
End Sub ' ReadWriteFile
 
 
Sub EnumATJobs(sArgComputer)
' Version 1.0
' Writen by Krystian Karia
' Dated 16/03/2009
 
' Runs the SchTasks.exe tool to query remote shceduled tasks
' on the computers passed to us and log to a global variable
 
' Catch errors ourselves
	On Error Resume Next
 
' Declare the local variables
	Dim WshShell, objWMIService, colScheduledJobs, objJob
	Dim strOutput
 
' Bind to WMI
	Set objWMIService = GetObject("winmgmts:" _
		& "{impersonationLevel=impersonate}!//" & sArgComputer & "\root\cimv2")
 
' Enumerate teh Win32_ScheduledJob
		If Err.Number = 0 Then
			Set colScheduledJobs = objWMIService.ExecQuery _
				("SELECT * FROM Win32_ScheduledJob")
				
				For Each objJob in colScheduledJobs
					strOutput = objJob.Caption
				Next
			Else
				ShowProgress "Unable to bind to " & sArgComputer
				gsOutput = gsOutput & sArgComputer & ",Unable to bind to" & vbNewLine
				Err.Clear
		End If
 
		If Trim(strOutput) <> "" Then
			If InStr(UCase(strOutput), "INFECTED SCAN") > 0 Then 
				ShowProgress "Caption: " & strOutput & vbNewLine
 
				gsOutput = gsOutput & sArgComputer & "," & strOutput & vbNewLine
				strOutput = ""
			End If 
		End If
 
 
End Sub ' EnumATJobs
 
Private Function Reachable(strComputer)
' Version 1.0
 
     On Error Resume Next
 
    Dim wmiQuery, objWMIService, objPing, objStatus
    
    wmiQuery = "Select * From Win32_PingStatus Where " & _
    	"Address = '" & strComputer & "'"
    
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery(wmiQuery)
    
    For Each objStatus in objPing
        If IsNull(objStatus.StatusCode) Or objStatus.Statuscode <> 0 Then
            Reachable = False 'if computer is unreacable, return false
        Else
            Reachable = True 'if computer is reachable, return True
        End If
    Next
End Function ' Reachable
 
Private Sub ShowProgress(sComment)
 
	WScript.Echo sComment
 
End Sub

Open in new window

bsharath

ASKER
Krystian
I get the results but they dont seem in to clear.
Can i get them like

Machine name permsission error
Machine name Timed out
Machine name "Infected Scan"
Machine name "Infected scan01'
Machine name "No scheduled scans"

Any name after the infected in the scan name is right that means the scan is available.
Why i say this is i could see some scans as "Infected scan001" and so on. So 'Infected" is what we need to find
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Krys_K

Hi There
Try this one, hopefully i've understood you correctly.
Regards
Krystian

Option Explicit
 
 
' Global Variables
	Dim gsOutput, gsHeader
 
	Call ReadWriteFile
	
Sub ReadWriteFile()
' Version 1.0
 
' Declare Variables
 	Dim fso, oFile
	Dim arrComputers
	Dim sReadResults
	Dim i
 
' fso Constants
	Const ForReading = 1                              'Used for file open
	Const ForWriting = 2                              'Used for file open
	Const ForAppending = 8                            'Used for file open
 
' User Defined constants
	Const sFileLocation = "C:\ComputerList.txt" 	  '<_______Change to suit
	Const sSaveFile = "C:\SchedTasksReport.csv"		  '<_______Change to suit
 
' Set the Header
	gsHeader = "ComputerName,Task / Comment" & vbNewLine
	
' Create Objects
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set oFile = fso.OpenTextFile(sFileLocation, ForReading, False)
	
		If Err.Number <> 0 Then
			WScript.Echo "Error reading File " & sfileLocation
			Exit Sub
		End If
	
' Read the whole contents of the File
	Do While oFile.AtEndOfStream <> True
		sReadResults = oFile.ReadAll
	Loop
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
 
' Create an array of computers
	arrComputers = Split(sReadResults, vbNewLine)
	
' Loop each computer
	For i = 0 to Ubound(arrComputers)
		If arrComputers(i) = "" Then 
			Exit For
		End If 
	
			If Reachable(arrComputers(i)) = True Then
				ShowProgress arrComputers(i)
				Call EnumSchedTasks(arrComputers(i))
			Else
				ShowProgress arrComputers(i) & " Unreachable"
				gsOutput = gsOutput & arrComputers(i) & ",Offline" & vbNewLine
			End If
		
	Next ' i	
 
' Write or append the results
	If Not fso.FileExists(sSaveFile) Then
		Set oFile = fso.OpenTextFile(sSaveFile, ForWriting, True)
			If Err.Number <> 0 Then
				ShowProgress "Error creating file " & sSaveFile
				Exit Sub
			End If
		
		ofile.Write(gsHeader & gsOutput)
	Else
		Set oFile = fso.OpenTextFile(sSaveFile, ForAppending, False)
			If Err.Number <> 0 Then
				ShowProgress "Error opening file " & sSaveFile
				Exit Sub
			End If
 
		ofile.Write(gsOutput)
	End If 
 
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
	
 
End Sub ' ReadWriteFile
 
 
Sub EnumSchedTasks(sArgComputer)
' Version 1.0
' Writen by Krystian Karia
' Dated 16/03/2009
 
' Runs the SchTasks.exe tool to query remote shceduled tasks
' on the computers passed to us and log to a global variable
 
' Catch errors ourselves
'	On Error Resume Next
 
' Declare the local variables
	Dim WshShell, objCmdExec
	Dim strCmdTool, strCmdArgs1, strCmdArgs2
	Dim strOutput, iQuit
 
	Const Exec_Running = 0
	Const Exec_Finished = 1
 
' Create Objects
	Set WshShell = CreateObject("Wscript.Shell")
 
 
' Set the command line arguments to work with
	strCmdTool = "schtasks.exe"			' Full path and filename of cmd line tool
	strCmdArgs1 = " /Query /S "			' Cmd line arguments
	strCmdArgs2 = " /FO CSV /NH "		' Cmd line arguments
 
' Run the commandline tool and get the output
	Set objCmdExec = WshShell.Exec(strCmdTool & strCmdArgs1 & sArgComputer & strCmdArgs2)
 
		iQuit = 1
		Do Until (objCmdExec.Status <> Exec_Running Or iQuit = 10)
			WScript.Sleep 1000		'<___ Increase or decrease if required (1000 = 1 Second)
			iQuit = iQuit + 1
		Loop 
		
		If iQuit = 10 Then
		'Terminate if it takes too long
			ShowProgress "Terminating"
			objCmdExec.Terminate
		End If
 
			strOutput = strOutput & objCmdExec.StdOut.ReadAll
 
				If (Err.Number <> 0) Or strOutput = "" Then
					ShowProgress "An Error occurred. Try running manually (in Cmd) to host to see the problem"
					gsOutput = gsOutput & sArgComputer & "Timed Out - Check permissions" & vbNewLine
					Err.Clear
				End If
 
		If Trim(strOutput) <> "" Then
			If InStr(UCase(Replace(strOutput, vbNewLine, "")), "INFECTED") > 0 Then 
				ShowProgress "TaskName: " & Replace(Left(strOutput, InStr(strOutput, ",") -1), vbNewLine, "") & vbNewLine
			
				gsOutput = gsOutput & sArgComputer & "," & Replace(Left(strOutput, InStr(strOutput, ",") -1), vbNewLine, "") & vbNewLine
				strOutput = ""
			End If 
		End If
 
 
End Sub ' EnumSchedTasks
 
Private Function Reachable(strComputer)
' Version 1.0
 
     On Error Resume Next
 
    Dim wmiQuery, objWMIService, objPing, objStatus
    
    wmiQuery = "Select * From Win32_PingStatus Where " & _
    	"Address = '" & strComputer & "'"
    
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery(wmiQuery)
    
    For Each objStatus in objPing
        If IsNull(objStatus.StatusCode) Or objStatus.Statuscode <> 0 Then
            Reachable = False 'if computer is unreacable, return false
        Else
            Reachable = True 'if computer is reachable, return True
        End If
    Next
End Function ' Reachable
 
Private Sub ShowProgress(sComment)
 
	WScript.Echo sComment
 
End Sub

Open in new window

bsharath

ASKER
I get the msg boxes on the screen. Can i not supress it. Just get the results at the end
bsharath

ASKER
I get the msg boxes on the screen. Can i not supress it. Just get the results at the end
Your help has saved me hundreds of hours of internet surfing.
fblack61
Krys_K

Sure, If you run it in a command window, it would show them in the window instead.
However, This one has no messageboxes unless a major error occurs. this is why running scripts in the cmd prompt is usally more convenient.
If you want to show all messages for debug purposes then just set the variable gblnNoMsgbox from True to False at the top
 Regards
Krystian

Option Explicit
 
 
' Global Variables
	Dim gsOutput, gsHeader
 
' Set to True if you want no message boxes to pop 
' up. Still shows errors that stops the script
	Const gblnNoMsgbox = True
 
	Call ReadWriteFile
	
Sub ReadWriteFile()
' Version 1.0
 
' Declare Variables
 	Dim fso, oFile
	Dim arrComputers
	Dim sReadResults
	Dim i
 
' fso Constants
	Const ForReading = 1                              'Used for file open
	Const ForWriting = 2                              'Used for file open
	Const ForAppending = 8                            'Used for file open
 
' User Defined constants
	Const sFileLocation = "C:\ComputerList.txt" 	  '<_______Change to suit
	Const sSaveFile = "C:\SchedTasksReport.csv"		  '<_______Change to suit
 
' Set the Header
	gsHeader = "ComputerName,Task / Comment" & vbNewLine
	
' Create Objects
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set oFile = fso.OpenTextFile(sFileLocation, ForReading, False)
	
		If Err.Number <> 0 Then
			WScript.Echo "Error reading File " & sfileLocation
			Exit Sub
		End If
	
' Read the whole contents of the File
	Do While oFile.AtEndOfStream <> True
		sReadResults = oFile.ReadAll
	Loop
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
 
' Create an array of computers
	arrComputers = Split(sReadResults, vbNewLine)
	
' Loop each computer
	For i = 0 to Ubound(arrComputers)
		If arrComputers(i) = "" Then 
			Exit For
		End If 
	
			If Reachable(arrComputers(i)) = True Then
				If gblnNoMsgbox = False Then
					ShowProgress arrComputers(i)
				End If 
				Call EnumSchedTasks(arrComputers(i))
			Else
				If gblnNoMsgbox = False Then
					ShowProgress arrComputers(i) & " Unreachable"
				End If
				gsOutput = gsOutput & arrComputers(i) & ",Offline" & vbNewLine
			End If
		
	Next ' i	
 
' Write or append the results
	If Not fso.FileExists(sSaveFile) Then
		Set oFile = fso.OpenTextFile(sSaveFile, ForWriting, True)
			If Err.Number <> 0 Then
				ShowProgress "Error creating file " & sSaveFile
				Exit Sub
			End If
		
		ofile.Write(gsHeader & gsOutput)
	Else
		Set oFile = fso.OpenTextFile(sSaveFile, ForAppending, False)
			If Err.Number <> 0 Then
				ShowProgress "Error opening file " & sSaveFile
				Exit Sub
			End If
 
		ofile.Write(gsOutput)
	End If 
 
	
' Close the file
	oFile.Close
	
' Release the object from memory
	Set oFile = Nothing
	
 
End Sub ' ReadWriteFile
 
 
Sub EnumSchedTasks(sArgComputer)
' Version 1.0
' Writen by Krystian Karia
' Dated 16/03/2009
 
' Runs the SchTasks.exe tool to query remote shceduled tasks
' on the computers passed to us and log to a global variable
 
' Catch errors ourselves
'	On Error Resume Next
 
' Declare the local variables
	Dim WshShell, objCmdExec
	Dim strCmdTool, strCmdArgs1, strCmdArgs2
	Dim strOutput, iQuit
 
	Const Exec_Running = 0
	Const Exec_Finished = 1
 
' Create Objects
	Set WshShell = CreateObject("Wscript.Shell")
 
 
' Set the command line arguments to work with
	strCmdTool = "schtasks.exe"			' Full path and filename of cmd line tool
	strCmdArgs1 = " /Query /S "			' Cmd line arguments
	strCmdArgs2 = " /FO CSV /NH "		' Cmd line arguments
 
' Run the commandline tool and get the output
	Set objCmdExec = WshShell.Exec(strCmdTool & strCmdArgs1 & sArgComputer & strCmdArgs2)
 
		iQuit = 1
		Do Until (objCmdExec.Status <> Exec_Running Or iQuit = 10)
			WScript.Sleep 1000		'<___ Increase or decrease if required (1000 = 1 Second)
			iQuit = iQuit + 1
		Loop 
		
		If iQuit = 10 Then
		'Terminate if it takes too long
			If gblnNoMsgbox = False Then
				ShowProgress "Terminating"
			End If
			objCmdExec.Terminate
		End If
 
			strOutput = strOutput & objCmdExec.StdOut.ReadAll
 
				If (Err.Number <> 0) Or strOutput = "" Then
					If gblnNoMsgbox = False Then
						ShowProgress "An Error occurred. Try running manually (in Cmd) to host to see the problem"
					End If
					gsOutput = gsOutput & sArgComputer & "Timed Out - Check permissions" & vbNewLine
					Err.Clear
				End If
 
		If Trim(strOutput) <> "" Then
			If InStr(UCase(Replace(strOutput, vbNewLine, "")), "INFECTED") > 0 Then 
				If gblnNoMsgbox = False Then
					ShowProgress "TaskName: " & Replace(Left(strOutput, InStr(strOutput, ",") -1), vbNewLine, "") & vbNewLine
				End If 
				
				gsOutput = gsOutput & sArgComputer & "," & Replace(Left(strOutput, InStr(strOutput, ",") -1), vbNewLine, "") & vbNewLine
				strOutput = ""
			End If 
		End If
 
 
End Sub ' EnumSchedTasks
 
Private Function Reachable(strComputer)
' Version 1.0
 
     On Error Resume Next
 
    Dim wmiQuery, objWMIService, objPing, objStatus
    
    wmiQuery = "Select * From Win32_PingStatus Where " & _
    	"Address = '" & strComputer & "'"
    
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery(wmiQuery)
    
    For Each objStatus in objPing
        If IsNull(objStatus.StatusCode) Or objStatus.Statuscode <> 0 Then
            Reachable = False 'if computer is unreacable, return false
        Else
            Reachable = True 'if computer is reachable, return True
        End If
    Next
End Function ' Reachable
 
Private Sub ShowProgress(sComment)
 
	WScript.Echo sComment
 
End Sub

Open in new window

bsharath

ASKER
Thanks
The poroblem now is
I dont want any of these
NextRunTime
I just want to know if there is a scheduled scan by the name "Infected Scan" or "Infected scan01" or "Infected Scan002"
Yes or No. So that would be easy to filter.

Now i get all the scan names and its difficult to order them for 4000 + systems....
bsharath

ASKER
Thanks
The poroblem now is
I dont want any of these
NextRunTime
I just want to know if there is a scheduled scan by the name "Infected Scan" or "Infected scan01" or "Infected Scan002"
Yes or No. So that would be easy to filter.

Now i get all the scan names and its difficult to order them for 4000 + systems....
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Krys_K

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
bsharath

ASKER
Thank U