There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Solved: Actually windows 2003 but command prompt related -


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
31-Jan-2006, 12:05 PM #1
Solved: Actually windows 2003 but command prompt related -
I have this -

shutdown.exe /s /f /m \\MYCOMPUTER /t 15 /c "This PC is now being shut down for Administrative tasks. Any files left open will be lost."

In a batch file (we will call it batch.bat) I want MYCOMPUTER to be a variable and the information to come from a text file (we will call this computerlist.txt) that is going to list computer names like this.

MYCOMPUTER
THEIRCOMPUTER
YOURCOMPUTER

How would you loop this batch.bat command for each line in the computerlist.txt file and input it as a variable? Note computerlist.txt will be a changing document and some days may have 10 entries and others may have hundreds but the format won't change.
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
31-Jan-2006, 01:54 PM #2
Never mind I am deciding to do this in VBS form.
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
31-Jan-2006, 08:06 PM #3
I know this sounds kind of crazy but you could use Shutdown or Poweroff with a batch file and have it loop thru your entire DHCP IP address range. This is another thing I can easily script in Linux, if Linux had the capability to shutdown a windows computer. Maybe there is a command line linux utility to do this. If there is, I could easily script it with a file list of all your computer names. If you installed Cygwin or something similar on Windows to give you a shell prompt, it would be rather easy. The windows command line just doesn't have the power of shell scripting on nix systems.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
31-Jan-2006, 10:01 PM #4
I know you marked this solved but I think this should work in a batch file.

FOR /F "tokens=1" %%I IN (computers.txt) DO shutdown.exe -s -f -m \\%%I -t 20

I am getting an access denied but I think it is a policy setting I have on my computers here at home. This should work if the computers are attached to a domain and are NT based.

I think this is the reason why I get access denied.
http://www.experts-exchange.com/Oper..._20756919.html
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
Squashman's Avatar
Distinguished Member with 12,598 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
01-Feb-2006, 07:23 PM #5
Now I feel dumb. I finally got it to work. I thouhgt I had Simple File Sharing turned off but apparently not. Because I had it checked it kept giving me that Access Denied message. Unchecked it and now it works. Yeah. I know you got this working thru a VBscript but thought I would take a crack at it and I got it to work. Yeah for me.
__________________
I hate asking the same question twice!
How to ask questions the smart way!
Microsoft MVP - Windows Shell/User
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
01-Feb-2006, 09:37 PM #6
Ahhh okay I see so you would do For /f to parse the file tokens=1 ?is for each line? in the file specified then do indicates it needs to then run a command and shutdown with switches. Makes sense kicking myself for not thinking of this.

If you look at the Development page you will see why I went to vbs.

now I have it so it only runs the command on any PC that is actually active. I am also going to modify it further to output the ones down and give me a "log file"

So In all I am making this more complex and want to go to vbs.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:06 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.