Script to search for a computer name

T

ts

I have about 40 PCs in two rooms. At the moment, I use
batch file to shut down all the PCs in these two room. the
drawback is that if one of the pc is turned off, this
batch file take a long time to finish.
I would like to have a script to search for a computer
name so that it can shutdown right away instead of waiting
for timeout, and then proceed the next command line.
Thanks
 
T

Torgeir Bakken (MVP)

ts said:
I have about 40 PCs in two rooms. At the moment, I use
batch file to shut down all the PCs in these two room. the
drawback is that if one of the pc is turned off, this
batch file take a long time to finish.
I would like to have a script to search for a computer
name so that it can shutdown right away instead of waiting
for timeout, and then proceed the next command line.
Thanks

Hi

Ping the computer first and test for the text TTL to see if it is alive...

Command line solutions:

ping.exe -n 1 CompNameHere | find "TTL="

http://groups.google.com/groups?q=p....cmdprompt.admin&hl=en&lr=&ie=UTF-8&scoring=d
 
W

Walter Schulz

I have about 40 PCs in two rooms. At the moment, I use
batch file to shut down all the PCs in these two room. the
drawback is that if one of the pc is turned off, this
batch file take a long time to finish.

====Computerlist.csv====
computer1;192.168.1.1
computer2;192.168.1.2
====EOF=============

===SHUTDOWNALL.CMD===
for /F "tokens=1 delims=;" %%a in (computerlist.csv) do call :Step2
%%a
REM above is a single line ... no CR/LF
GOTO :EOF

:step2
for /F %%b in ('ping %1 -n 1 ^|find /I "Reply from"') do call
:shutthismachinedown %1
GOTO :EOF

:Shutthismachinedown
shutdown %1 <additional commands as requested>
GOTO :EOF
===EOF====

Ciao, Walter
 
G

Guest

Can i schedule this batch file to run ?? say 9:00pm it
will automatically run ?? Thanks
 
G

Guest

Can i schedule this batch file to run ?? say 9:00pm it
will automatically run ?? Thanks
 
G

Guest

can this batch file work with DHCP IP address ?? Thanks
Walter ??? it looks like to me that this only work if you
specify a static IP ???
 
W

Walter Schulz

can this batch file work with DHCP IP address ?? Thanks
Walter ??? it looks like to me that this only work if you
specify a static IP ???

"tokens=1 delims=;" means picking up the computername instead of the
IP address. Therefore a static IP entry isn't used at all.

Ciao, Walter
 
W

Walter Schulz

Can i schedule this batch file to run ?? say 9:00pm it
will automatically run ?? Thanks

You can schedule anything you want by using Start -> Settings ->
Control Panel -> Scheduled Tasks. You have to run this task under a
account which has the privilege to shutdown the machines over the
network. .
Put this in front of the first CMD to call
cd \<path where your batches reside.>
example:
cd \utils\batches\shutdownall

Ciao, Walter
 

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