Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-04-10
7
Medium Priority
?
592 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 1000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

916 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