Tom
Thu Jun 26 08:25:21 CDT 2008
On Jun 26, 3:04 am, "L=FCko Willms" <l.wil...@domain.invalid> wrote:
> This concerns a logon-script, which assigns drive letters to network
> drives, like in
>
> WshNetwork.MapNetworkDrive "E:", "\\server-x\Public"
>
> The problem is that not all servers (rather peers) are not always
> switched on, and trying to map drives to those computers results in
> long wait times and eventually invalid drive mappings.
>
> But the WshNetwork object offers me -- as far as I can find out --
> no means to verify first, if the target computer is actually
> reachable.
>
> I would like to have a method which enumerates all computers which
> are currently logged on in a domain, or searching computers on the LAN
> generally, as the "Search computer" menu item in "Network
> Neighbourhood" (or how that is called in english).
>
> Is that possible and can anybody point me to some way to do that,
> please?
>
> Cheers,
> L.W.
If this is in XP or above, there is a WMI solution to pinging a
machine found in the MS Technet Script Center examples ...
strMachines =3D "atl-dc-01;atl-win2k-01;atl-nt4-01;atl-dc-02"
aMachines =3D split(strMachines, ";")
For Each machine in aMachines
Set objPing =3D GetObject("winmgmts:
{impersonationLevel=3Dimpersonate}")._
ExecQuery("select * from Win32_PingStatus where address =3D '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0
Then
WScript.Echo("Computer " & machine & " is not reachable")
End If
Next
Next
If the machines run other OSs, there is also a solution that uses the
command line PING, as Pegasus illustrated, but that is wrapped in VBS
code. A copy can be found here:
http://groups.google.com/group/
microsoft.public.windows.server.scripting/msg/be46f11523413f4e
Pinging a server does not guarantee it is operational, but it is valid
in all cases where the machine is turned on and functioning. The only
time it will fail is if it is on, but failed in some other way. In
such cases, it might respond to a ping, but fail to service other
requests - probably a low percentage likelihood.
Tom Lavedas
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
http://members.cox.net/tglbatch/wsh/