I'm not too familiar with batch files for Windows, so this may seem like a beginner question. How could I "loop", or repeat, a command like the following?
shutdown -a
I'm not too familiar with batch files for Windows, so this may seem like a beginner question. How could I "loop", or repeat, a command like the following?
shutdown -a
I agree with commenter @reuben, that you possible should look for other options (including getting that coworker himself "fixed"), but anyway here is a way to run the command repeatedly:
:loop
shutdown -a
goto loop
Note that this might still leave a window, where it cannot cancel a shutdown because it is not "fast" enough.
Also it causes "mild terror" to your system, at least on the csrss.exe
(or conhost.exe
) process, because the console window will be busy printing messages. Thus you might want to redirect the output at least (shutdown -a > NUL 2>&1
) and/or introduce some delay beteween the calls to shutdown
. Of course the later increases the risk of not "catching" a shutdown significantly.
All in all that is not a good solution to your problem. Sorry.
Are you trying to shutdown multiple remote computers? You can write a script that ssh into each machine and send it the shutdown command:
ssh user1@remote_computer1 shutdown
ssh user2@remote_computer2 shutdown
...
If you mean you what to loop the shutdown command on the same computer, you can put the shutdown command in your ~/.bashrc, if you really want to. But make sure you have a very good reason to do so.