Repeatedly execute a Windows command from a batch file?

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:

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.

Need Your Help

Drop down list keeps selecting last item from list

php html mysql html.dropdownlistfor

I have an issue with an assignment I'm working on at the moment. I have a drop down list where I can select a user to send them a message on my website. The problem is that every time I try to select

Json class handling in android application

php android

i have an activity like message box and i want to get jason response of a php page: my code is something like this but the app crashes! here are my codes ! i dont know what happens but in my stack ...