Computing.Net > Forums > Programming > Batch file to remotely shutdown

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to remotely shutdown

Reply to Message Icon

Name: stormy
Date: December 2, 2005 at 15:38:15 Pacific
OS: Windows & Linux
CPU/Ram: p4 2.8 Ghz 128 mb ram
Comment:

On my home network I have 4 Windows boxes. 3 are downstairs and 1 is in my room. All of them are pretty lax on security since they have no internet connection. Anyway I can log into each one using null sessions (no user, no pass). So I'm pretty sure I can use shutdown's /m feature to remotely shut them down. Basically I need a batch file that will connect to each and shut them down. I was thinking it would go like this:

step-BY-STEP
1.Get a list of computers (filter by //) and output (>) to file
-net view > hosts
2.Establish NULL session with each computer
-SET TARGET=blah (read from lines of file)
-NET USE %TARGET%\IPC$ * /USER: (%TARGET% should be in \\HOSTNAME format)
3. If it succeeds, shutdown
-IF ERRORLEVEL 1 GOTO :shutdown ERRORLEVEL 2 :skip, go back to step 2

But sadly, I suck with batch scripting so I really need your help.
-Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: December 3, 2005 at 06:28:22 Pacific
Reply:

If you only have 4 machines that need to be shutdown, why do you need the script to dynamically get a list of the computers or attemt a null session?

Just create a batch script with 4 shutdown commands (1 for each computer). If a particular computer is on it will shut down. If its already off it won't matter.

shutdown.exe -s -m \\computername1 -t -f
shutdown.exe -s -m \\computername2 -t -f
shutdown.exe -s -m \\computername3 -t -f
shutdown.exe -s -m \\computername4 -t -f

There are some other switches as well that you may want to investigate.

Michael J


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file to remotely shutdown

Batch file to remote shutdown network PC's www.computing.net/answers/programming/batch-file-to-remote-shutdown-network-pcs/19105.html

Batch File to Change Database .ini www.computing.net/answers/programming/batch-file-to-change-database-ini/14429.html

admin priveles for batch file www.computing.net/answers/programming/admin-priveles-for-batch-file/17831.html