I have a script that uses a txt file with server names to check if a specific service is running. However, if a condition is met, the script ends and doesn't continue on to the next server. Here is my script. Do I need a Continue For or Exit For statement somewhere?
DIM objFile
DIM CurrTime
CurrTime = Now()
Const FOR_READING = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\users\***\desktop\winscripts\fastback\replication.txt", FOR_READING)
strComputer = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputer, vbCrLf)
For Each strComputer In arrComputers
'Set variables for Windows Process to investigate (Fastback DR Phase 1 or 2 in this case)
strProcess = "fastbackdrph1.exe"
strProcess2 = "fastbackdrph2.exe"
Set wbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set wbemServices = wbemLocator.ConnectServer(strComputer)
Set wbemObjectSet = wbemServices.InstancesOf("Win32_Process")
Set objShell = WScript.CreateObject("WScript.shell")
For Each wbemObject In wbemObjectSet
'If Process strProcess (DR Phase 1) is running, Tell me
If LCase(wbemObject.Name) = strProcess Then
wscript.echo CurrTime & " DR Phase 1 is running on " & strComputer
wscript.quit
'If Process strProcess (DR Phase 2) is running, Tell me
ElseIf LCase(wbemObject.Name) = strProcess2 Then
wscript.echo CurrTime & " DR Phase 2 is running on " & strComputer
wscript.quit
End If
Next
'If neither strProcess or strProcess2 are not running, Tell me.
wscript.echo CurrTime & " DR is not running on " & strComputer
Next