Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-04-10
7
Medium Priority
?
591 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
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…
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…
Suggested Courses

705 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