I am attempting to make a batch file that will shut down every computer on my network. I am fairly new to batch in general but I am eager to learn. Here is what I have, apparently it cannot connect to my network itself and ends up only shutting down the computer I am working on. Is it possible, any help? Thanks.
Here is what I have:
@Echo off
cd\
Echo Netshut=Program
REM ****************************
REM * Program Variables *
REM ****************************
set varcomputer=EP-1-1.mysnowleopard.local
goto loop
:EP-1-1.mysnowleopard.local
set varcomputer=EP-1-2.mysnowleopard.local
goto loop
:EP-1-2.mysnowleopard.local
set varcomputer=EP-1-3.mysnowleopard.local
goto loop
:EP-1-3.mysnowleopard.local
set varcomputer=EP-1-4.mysnowleopard.local
goto loop
:EP-1-4.mysnowleopard.local
set varcomputer=EP-1-5.mysnowleopard.local
goto loop
:EP-1-5.mysnowleopard.local
set varcomputer=EP-1-6.mysnowleopard.local
goto loop
:EP-1-6.mysnowleopard.local
set varcomputer=EP-1-7.mysnowleopard.local
goto loop
:EP-1-7.mysnowleopard.local
set varcomputer=EP-1-8.mysnowleopard.local
goto loop
:EP-1-8.mysnowleopard.local
set varcomputer=EP-1-9.mysnowleopard.local
goto loop
:EP-1-9.mysnowleopard.local
set varcomputer=EP-1-10.mysnowleopard.local
goto loop
:EP-1-10.mysnowleopard.local
set varcomputer=EP-1-11.mysnowleopard.local
goto loop
:EP-1-11.mysnowleopard.local
set varcomputer=EP-1-12.mysnowleopard.local
goto loop
:EP-1-12.mysnowleopard.local
set varcomputer=EP-1-13.mysnowleopard.local
goto loop
:EP-1-13.mysnowleopard.local
set varcomputer=EP-1-14.mysnowleopard.local
goto loop
:EP-1-14.mysnowleopard.local
set varcomputer=EP-1-15.mysnowleopard.local
goto loop
:EP-1-15.mysnowleopard.local
set varcomputer=EP-2-1.mysnowleopard.local
goto loop
:EP-2-1.mysnowleopard.local
set varcomputer=EP-2-2.mysnowleopard.local
goto loop
:EP-2-2.mysnowleopard.local
set varcomputer=EP-2-3.mysnowleopard.local
goto loop
:EP-2-3.mysnowleopard.local
set varcomputer=EP-2-5.mysnowleopard.local
goto loop
:EP-2-5.mysnowleopard.local
set varcomputer=EP-2-6.mysnowleopard.local
goto loop
:EP-2-6.mysnowleopard.local
set varcomputer=EP-2-7.mysnowleopard.local
goto loop
:EP-2-7.mysnowleopard.local
set varcomputer=EP-2-8.mysnowleopard.local
goto loop
:EP-2-8.mysnowleopard.local
set varcomputer=EP-2-9.mysnowleopard.local
goto loop
:EP-2-9.mysnowleopard.local
set varcomputer=EP-2-10.mysnowleopard.local
goto loop
:EP-2-10.mysnowleopard.local
set varcomputer=EP-2-11.mysnowleopard.local
goto loop
:EP-2-11.mysnowleopard.local
set varcomputer=EP-2-12.mysnowleopard.local
goto loop
:EP-2-12.mysnowleopard.local
set varcomputer=EP-2-13.mysnowleopard.local
goto loop
:EP-2-13.mysnowleopard.local
set varcomputer=EP-2-14.mysnowleopard.local
goto loop
:EP-2-14.mysnowleopard.local
set varcomputer=EP-2-15.mysnowleopard.local
goto loop
:EP-2-15.mysnowleopard.local
Exit
REM ****************************
REM * Program *
REM ****************************
:loop
echo Shutting down %varcomputer%
shutdown -s -m \\%varcomputer% -t 30 -c "Your computer will now shut down, I am in complete control. Have a nice day, the end is near. "
goto %varcomputer%
Thanks again.
Batch Network Shutdown
Moderator: DosItHelp
Re: Batch Network Shutdown
Check the MS site first, and learn how remote shutdown is being done in a MS environment and what access rights you need.
http://search.microsoft.com/results.aspx?form=MSHOME&mkt=en-us&setlang=en-us&q=remote+shutdown+credentials
But here is another approach for your batch
http://search.microsoft.com/results.aspx?form=MSHOME&mkt=en-us&setlang=en-us&q=remote+shutdown+credentials
But here is another approach for your batch
Code: Select all
@Echo off
cd\
Echo Netshut=Program
REM ****************************
REM * Program Variables *
REM ****************************
call :loop EP-1-1.mysnowleopard.local
call :loop EP-1-2.mysnowleopard.local
call :loop EP-1-3.mysnowleopard.local
call :loop EP-1-4.mysnowleopard.local
call :loop EP-1-5.mysnowleopard.local
call :loop EP-1-6.mysnowleopard.local
call :loop EP-1-7.mysnowleopard.local
call :loop EP-1-8.mysnowleopard.local
call :loop EP-1-9.mysnowleopard.local
call :loop EP-1-10.mysnowleopard.local
call :loop EP-1-11.mysnowleopard.local
call :loop EP-1-12.mysnowleopard.local
call :loop EP-1-13.mysnowleopard.local
call :loop EP-1-14.mysnowleopard.local
call :loop EP-1-15.mysnowleopard.local
call :loop EP-2-1.mysnowleopard.local
call :loop EP-2-2.mysnowleopard.local
call :loop EP-2-3.mysnowleopard.local
call :loop EP-2-5.mysnowleopard.local
call :loop EP-2-6.mysnowleopard.local
call :loop EP-2-7.mysnowleopard.local
call :loop EP-2-8.mysnowleopard.local
call :loop EP-2-9.mysnowleopard.local
call :loop EP-2-10.mysnowleopard.local
call :loop EP-2-11.mysnowleopard.local
call :loop EP-2-12.mysnowleopard.local
call :loop EP-2-13.mysnowleopard.local
call :loop EP-2-14.mysnowleopard.local
call :loop EP-2-15.mysnowleopard.local
goto :eof
REM ****************************
REM * Program *
REM ****************************
:loop
echo Shutting down %1
shutdown -s -m \\%1 -t 30 -c "Your computer will now shut down, I am in complete control. Have a nice day, the end is near. "
goto :eof
Re: Batch Network Shutdown
Honestly I'm not familiar with remote stuff. If xl1000's script would work for you then a nested loop could make it easier.
Regards
aGerman
Code: Select all
@echo off &setlocal
for /l %%a in (1,1,2) do (
for /l %%b in (1,1,15) do (
echo Shutting down EP-%%a-%%b.mysnowleopard.local
shutdown -s -m \\EP-%%a-%%b.mysnowleopard.local -t 30 -c "Your computer will now shut down."
)
)
Regards
aGerman
Re: Batch Network Shutdown
Thanks for making that much more compact, simplified the variables a lot.
The main issue I am getting is it claims the path cannot be found when shutting down. I have full access to everything by the way so if needed I can alter anything on my network.
Any ideas? Thanks.
The main issue I am getting is it claims the path cannot be found when shutting down. I have full access to everything by the way so if needed I can alter anything on my network.
Any ideas? Thanks.