- Oct 28, 2003
- 2,635
- 0
- 71
I found this handy script.
Basically, I have a batch file that reads computers from a text file and runs the shutdown command on them.
The problem arrises though, if the machine is not powered on the script waits 30 seconds until it moves on to the next computer in the list.
So I found this handy VBS that pings a list of computers, and then outputs the results in a text file.
The problem with it however, is the list of computers to ping is hard coded into the script. I need it to ping the list of computers from a text file named "computers.txt" then I need the text file it creates to be named after the computer running the VBS script.
for example
server1 executes ping.vbs and then writes server1.txt to a dfs share \\domain\dfs\ping_results\server1.txt
Thank you for any help.
Here is the script I am working with.
strMachines = "computer1;computer2"
aMachines = split(strMachines, ";")
Set objRF = CreateObject("Scripting.FileSystemObject")
Set objPrintOut = objRF.CreateTextFile("Computer Name.txt")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
objPrintOut.WriteLine()
else objPrintOut.WriteLine(""& machine &"")
End If
Next
Next
ObjPrintOut.Close
Basically, I have a batch file that reads computers from a text file and runs the shutdown command on them.
The problem arrises though, if the machine is not powered on the script waits 30 seconds until it moves on to the next computer in the list.
So I found this handy VBS that pings a list of computers, and then outputs the results in a text file.
The problem with it however, is the list of computers to ping is hard coded into the script. I need it to ping the list of computers from a text file named "computers.txt" then I need the text file it creates to be named after the computer running the VBS script.
for example
server1 executes ping.vbs and then writes server1.txt to a dfs share \\domain\dfs\ping_results\server1.txt
Thank you for any help.
Here is the script I am working with.
strMachines = "computer1;computer2"
aMachines = split(strMachines, ";")
Set objRF = CreateObject("Scripting.FileSystemObject")
Set objPrintOut = objRF.CreateTextFile("Computer Name.txt")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
objPrintOut.WriteLine()
else objPrintOut.WriteLine(""& machine &"")
End If
Next
Next
ObjPrintOut.Close