Efficient way to determine if PC's are on or off

N

nicough

Hi
I'm looking for a way to query a text list of netbios PC names, and
detect if the PC is on or off.
I have 1000's of PC's on the network, so it need to be VERY quick.
Maybe one that supports multithreading?

Requirements:
-Must run from Windows 2K/XP command line, preferably standalone app
(ie not require an installer)
-Fast
-Utility, or BAT or VBS solution.

Additionally, it would be handy to be able to get the IP address for
the PC, and do a tracert type of funtion, to see if the IP actually
belongs to a different PC name, eg when an old PC is replaced by a new
PC, and both have the same IP.

Many thanks
Nick
_nicou_
 
A

Al Dunbar [MS-MVP]

Hi
I'm looking for a way to query a text list of netbios PC names, and
detect if the PC is on or off.

In the general case, no. Assuming no wake-on-LAN capability, no script is
able to determine the status of a computer that does not respond to its
probing as to whether it is powered off, physically disconnected from the
network, living in a subnet not currently accessible, or booted with a
floppy to run a diagnostic.
I have 1000's of PC's on the network, so it need to be VERY quick.
Maybe one that supports multithreading?

Requirements:
-Must run from Windows 2K/XP command line, preferably standalone app
(ie not require an installer)
-Fast
-Utility, or BAT or VBS solution.

Neither BAT nor VBS supports "multithreading", but you could perhaps run
multiple instances, each of which deals with only a subset of all
workstations.
Additionally, it would be handy to be able to get the IP address for
the PC, and do a tracert type of funtion, to see if the IP actually
belongs to a different PC name, eg when an old PC is replaced by a new
PC, and both have the same IP.

You want it fast, yet you are asking for additional info that can only take
time to acquire...

/Al
 
C

Clay Calvert

Hi
I'm looking for a way to query a text list of netbios PC names, and
detect if the PC is on or off.
I have 1000's of PC's on the network, so it need to be VERY quick.
Maybe one that supports multithreading?

If all of these workstations are viewable in the Network Neighborhood,
then a fairly reliable, yet very quick method is simply:

net view
and
net view /domain:DOMAINorWORKGROUP

I've used this syntax thousands of times for performing tasks against
powered-on computers. Though it can take a few minutes for a computer
to drop out of the browse list, this is still, at least for me, very
adequate. It also isn't likely to be subject to replaced computer
syndrome.

Let's say you want to copy file.ext to the c:\folder directory on all
machines that don't have it. As a batch file:

for /f %%a in ('net view ^|find "\\"') do (
if not exist %%a\c$\folder md %%a\$\folder
if not exist %%a\c$\folder\file.ext do copy file.ext %%a\c$\folder)

Just a possibility.

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 
J

Jerold Schulman

Hi
I'm looking for a way to query a text list of netbios PC names, and
detect if the PC is on or off.
I have 1000's of PC's on the network, so it need to be VERY quick.
Maybe one that supports multithreading?

Requirements:
-Must run from Windows 2K/XP command line, preferably standalone app
(ie not require an installer)
-Fast
-Utility, or BAT or VBS solution.

Additionally, it would be handy to be able to get the IP address for
the PC, and do a tracert type of funtion, to see if the IP actually
belongs to a different PC name, eg when an old PC is replaced by a new
PC, and both have the same IP.

Many thanks
Nick
_nicou_


@echo off
if {%1}=={} @echo Syntax: PCOK filename&goto :EOF
if not exist %1 @echo Syntax: PCOK %1 not found.&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set file=%1
set /a cnt=0
for /f "Tokens=*" %%c in ('type %file%') do (
set /a cnt=!cnt! + 1
set wrk="%TEMP%\PCOK_!cnt!.bat"
call :pCOKOB "%%c" !cnt!>!wrk!
start /min /high CMD /c !wrk!
)
@ping -n 7 127.0.0.1>nul
for /f "Tokens=*" %%a in ('dir "%TEMP%\PCOK_*.log" /b') do (
type "%TEMP%\%%a"
del /q "%TEMP%\%%a"
)
del /q "%TEMP%\PCOK_*.bat"
endlocal
goto :EOF
:pCOKOB
@echo set IP=NONE
@echo for /f "Tokens=3* Delims=: " %%%%i in ('@ping -n 1 -w 250 %1^^^|find "TTL="'^) do set IP=%%%%i
@echo @echo %1,"%%IP%%"^>"%TEMP%\PCOK_%2.log"
@echo exit
 
R

Reinhardt Kern

Hi
I'm looking for a way to query a text list of netbios PC names, and
detect if the PC is on or off.
I have 1000's of PC's on the network, so it need to be VERY quick.
Maybe one that supports multithreading?

Requirements:
-Must run from Windows 2K/XP command line, preferably standalone app
(ie not require an installer)
-Fast
-Utility, or BAT or VBS solution.

Hi Nick,
what is your role in your organisation?
Do you have administrative rights in your domain (domains)?
Do you have a list of computers?
Do you have a list of IP addresses?
Define "fast". I implemented a similar task as yours for about
6.000 computers and it runs for about 6 hours for the first run.


Tip 1)
The following batch file scans over a list of computers:
for /f %%a in ( list_of_computers.txt ) do call somebatch.cmd
and so you can start it parallel
for /f %%a in ( list_of_computers.txt ) do (
ping -n 5 localhost >nul 2>nul
start somebatch.cmd
)
The ping line slows the process down - otherwise you create
100s of processes.
I divided the task into 6 parallel batch files with 1.000
computers each. (Long time ago.)

Tip 2)
The PING.EXE of NT4 is much faster than the Win2000/XP version.
Use it for checking the on/off state of a known machine name or
IP address.

Tip 3)
NBTSTAT.EXE provides public information about the NETbios of
the asked machine. But if the machine is offline, the NBTSTAT
waits the usual 30 sec. SMB-timeout.

Tip 4)
Read information from remote registry with:
REG.EXE QUERY \\machine\HKLM\Software ...

Tip 5)
NLTEST.EXE gives you a list of computer names in NT4 domains.
ADSI or LDAP scripts are out in the web.
The Active Directory itself collects some interesting data.
e.g. last login, last password change.


Without more detailled information, I can give only bricks. You
have to build the house yourself.

Tip 6) goto the software deployment guys in your organisation.
Let them implement a hardware inventory script using WMI. So at
every logon the computer delivers the data into a central
database. (A lot of software deployment systems have this ability
built in.)

Reinhardt
 
N

nicough

All very helpful thanks.
Erik: Great tips thanks. Nice to know that NT4 ping is faster. I do
have domain admin rights, but dont want to rely on C$ or remote
registry access for this particular task. Also, some people never
restart their PC's (beyond my control) so I cant rely on startup/logon
scripts.
The PCOK batch file seems to work quite well. The output doesnt include
PCs which didnt reply the ping, but I can modify that.

Where does NET VIEW gather its information from? Does it rely on any
servers to gather this info? And if I switch a PC off, how long would
it take before it no longer exists in the NET VIEW list?

Thanks
Nick
 
J

Jerold Schulman

All very helpful thanks.
Erik: Great tips thanks. Nice to know that NT4 ping is faster. I do
have domain admin rights, but dont want to rely on C$ or remote
registry access for this particular task. Also, some people never
restart their PC's (beyond my control) so I cant rely on startup/logon
scripts.
The PCOK batch file seems to work quite well. The output doesnt include
PCs which didnt reply the ping, but I can modify that.

Where does NET VIEW gather its information from? Does it rely on any
servers to gather this info? And if I switch a PC off, how long would
it take before it no longer exists in the NET VIEW list?

Thanks
Nick

I believe net view gather information from the browse master.

I would use Active Directory instead.

See tip 9436 » How can I rapidly determine if a computer is available?
in the 'Tips & Tricks' at http://www.jsifaq.com
 
C

Clay Calvert

Where does NET VIEW gather its information from? Does it rely on any
servers to gather this info? And if I switch a PC off, how long would
it take before it no longer exists in the NET VIEW list?

As Jerry stated, the browse master holds the browse list, yet if that
server is unavailable then another computer will take over, unless the
browser service is disabled on every other comptuer.

It usually takes less than 12 minutes for a powered off machine to
disappear from the browse list.

When using AD not only is there no guarantee that a machine hasn't
been turned on in the last few minutes, the computer may not even
exist anymore. It can take months for a computer to disappear out of
AD if it isn't manually removed, for let's say a crashed machine
rebuilt with a new name.

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top