Solved

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

Posted on 2014-04-10
7
585 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 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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 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…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

710 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