Solved

restart windows 7 pc's using computer names listed in a text file

Posted on 2014-04-10
7
572 Views
Last Modified: 2014-04-11
Hey Experts!  I need to restart 20+ computers and I have their names in a text file.  I would really just like to run a batch script to restart the computers and have the script use the text file that contains the names.

Any help would be greatly appreciated!

(Easy question I know but I've tried to figure it out and now that frustration has built in, I need to let the real experts figure it out.)
0
Comment
Question by:samiam41
  • 4
  • 2
7 Comments
 
LVL 28

Expert Comment

by:becraig
ID: 39992663
for /f %a in (textfile.txt) do shutdown -r -f -m %a -c "Some reason for the shutdown"
0
 
LVL 10

Assisted Solution

by:Pramod Ubhe
Pramod Ubhe earned 250 total points
ID: 39993861
just run "shutdown -i" command on your computer and it will give you nice GUI options to reboot/shutdown remote hosts.
0
 
LVL 9

Author Comment

by:samiam41
ID: 39994226
@becraig,

here is what I put into my script (pullit.bat) which was in the same folder as the trainingroom_pcs.txt file.  I ran the script from my local pc from the cmd prmpt.

for /f %a in TrainingRoom_PCs.txt do shutdown -r -f -m %a -c "Admin restart"

-which yielded-

C:\Tools\Scripts>pullit
-c was unexpected at this time.

C:\Tools\Scripts>for /f a -c "Admin restart"

I added the full path to the location of the text file (c:\tools\script) which made the script look like this:

for /f %a in c:\scripts\tools\TrainingRoom_PCs.txt do shutdown -r -f -m %a -c "Admin restart"

-which yielded-

C:\Tools\Scripts>pullit
do was unexpected at this time.

C:\Tools\Scripts>for /f \scripts\tools\TrainingRoom_PCs.txt do shutdown -r -f -m
 a -c "Admin restart"

I tried removing the -c "Admin restart" and the outcome remained the same; no computers restarting in the training room.  Ideas/suggestions?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 9

Author Comment

by:samiam41
ID: 39994235
@pramod_ubhe,

Thank you for the option!  In all the time I've been doing this, I can't believe that a simple and easy option was available right in front of me.

I am waiting to see if [becraig] can offer any help with his solution before I close this out.  The two solutions in play have different venues that I would apply them to so I would like to see becraig's solution out.  If I don't hear back from him, I will close this out later today so this doesn't go on aimlessly.

Thanks again!
0
 
LVL 28

Accepted Solution

by:
becraig earned 250 total points
ID: 39994244
If you change from command line to bat or cmd the variable has to be declared as %%a

Eg

For /f %%a in (textfile.txt) do shutdown -r -f -m %%a -c "reason for shutdown"
0
 
LVL 9

Author Comment

by:samiam41
ID: 39994354
Got it!  Thanks.
0
 
LVL 9

Author Closing Comment

by:samiam41
ID: 39994368
Thanks for your time and suggestions.  Ideally I will utilize the scripting method for the next few mini-projects and the shutdown -i for the day to day needs.

I hope to work with you both again soon!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now