page 1 of 1
Comments: 3 | Views: 14912
Greater Monster
Greater Monster
Deconstruct! (Jacques Derrida 1930-2004)
The following script is actually direct from the CD that came with the book (Microsoft Windows Scripting Self-Paced Learning Guide)

Running it without arguments gives the correct message.

When I give one or more arguments, it gives an error:
pingmultiplecomputers.vbs(10,1) (null): 0x80041010

This is the command:
cscript pingmultiplecomputers.vbs computer1;computer2
where computer1 is the local machine and computer2 a machine on the network. I have no administrator rights on computer2

This is the script:
If WScript.Arguments.Count = 0 Then
WScript.Echo("You must enter a computer To ping")
Else
strMachines = WScript.Arguments.Item(0)
aMachines = split(strMachines, ",")
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
    WScript.Echo("machine " & machine & " is not reachable")
    Else
    wscript.Echo("reply from " & machine)
    End If
Next
Next
End If

Line 10 in the error message is this:
For Each objStatus In objPing

I run it on a W2K pro station.

What obvious point am I overlooking?
Minh
Minh
WOOH! WOOH!
If you don't have admin on comp2, then objPing is probably null for that comp, which means you can't execute your For Each statement. Just a guess, though.
sbc
sbc
GW R/Me
Surely the command should be
cscript pingmultiplecomputers.vbs computer1,computer2
(use comma instead of semicolon), as it splits the string on the , deliminator:
aMachines = split(strMachines, ",")
page 1 of 1
Comments: 3 | Views: 14912
Microsoft Communities