Solved

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

Posted on 2014-04-10
7
583 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 29

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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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 29

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

740 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