# help with remote shutdown of computer on a domain



## R_Tech (Apr 15, 2009)

I have created this bat to read the computer names from a text file. But for some reason it not working. I have created tons of other batch files that read from a text file, but for some reason this will not work. I figured I need some fresh eyes. 


P.S. it suppose to record the results into a text file


@echo off


set shut="C:\test.txt"


Echo ### Mid South Computer Shutdown

shutdown -s -f -m \\%shut% >>C:\regionshutdown\shutlog.log

@echo off


----------



## TheOutcaste (Mar 19, 2009)

Welcome to TSF!

All that does it try to shutdown a PC named "C:\test.txt", it won't actually read from the test file. Not too many commands support passing a list of PC names in a file.

You'll need something like this:

```
@echo off
set PCName=C:\test.txt
Echo ### Mid South Computer Shutdown
For /F "tokens=*" %%I In (%PCName%) Do shutdown -s -f -m \\%%I >>C:\regionshutdown\shutlog.log
```
If the path\filename to the text file contains spaces, you'll need to use this instead:

```
For /F "usebackq tokens=*" %%I In ("%PCName%") Do shutdown -s -f -m \\%%I >>C:\regionshutdown\shutlog.log
```
HTH

Jerry


----------



## Squashman (Apr 14, 2005)

I just use this.
http://users.telenet.be/jbosman/applications.html


----------



## JeffreyNYA (Apr 7, 2009)

there is PStools

http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx


----------

