Search
Sign In
Home
Recent
Media
Videos
Podcasts
Screencasts
Learn
Shows
Going Deep
ARCast.TV
The Id Element
See All Shows...
Forums
Coffeehouse
Tech Off
Feedback
Sandbox
Key Topics
Visual Studio
Continuum
Identity
Interoperability
Azure
Windows
Wiki
Search
Subscribe
Forums
>
Tech Off
Windows Scripting Learning Guide Chapter 4 and already stuck :(
Posted By:
Greater Monster
|
Oct 19th, 2004 @ 7:26 AM
page 1 of 1
Comments: 3 | Views: 14912
Delete
Edit
Reply
#Oct 19th, 2004 @ 7:26 AM
Greater Monster
Deconstruct! (Jacques Derrida 1930-2004)
In reply to {0}
Download:
[Pending]
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?
Delete
Edit
Reply
#Oct 19th, 2004 @ 7:48 AM
Minh
WOOH! WOOH!
In reply to {0}
Download:
[Pending]
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.
Delete
Edit
Reply
#Oct 19th, 2004 @ 9:01 AM
sbc
GW R/Me
In reply to {0}
Download:
[Pending]
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, ",")
Delete
Edit
Reply
#Oct 19th, 2004 @ 12:49 PM
Greater Monster
Deconstruct! (Jacques Derrida 1930-2004)
In reply to {0}
Download:
[Pending]
Thank you both, as you both had part of the solution.
It turned out I had no administrative rights on comp1 as well. Also I should have used the comma. I was alternating between two scripts which were the expect for the comma and semicolon.
I did use cscript but forgot to type it.
Again thanks to both of you, I am back on track (and got a reminder from that typo and syntax error are a programmers' nightmare).
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
page 1 of 1
Comments: 3 | Views: 14912
Forums
>
Tech Off
>
Windows Scripting Learning Guide Chapter 4 and already stuck :(
Be the first to comment!
Reply
Reply to root
In reply to {0}
Start related discussion
Forum:
Site Feedback
Tech Off
The 9 Guy Around The World
The Coffeehouse
Subject:
Tags
*Loading available tags