Jump to content

I need some help with a looping CMD/BAT


Recommended Posts

I am trying to loop shutdown so the user does not shutdown/restart the computer during the install process, then I need it to stop the shutdown loop after the CMD/BAT is done doing what I want it to do.

@echo off

:loop

shutdown -a

ping 127.0.0.1 -n 00 >nul

goto :loop

+++++++++

Then all my other CMD's

after that

+++++++++

Just need some help!!

Link to comment
Share on other sites


My understanding is that `shutdown -a` will abort a running shutdown procedure. It appears that you are wanting to prevent one from being issued, which is not the same. I would doubt that having a looping abort switch would be an efficient method of stopping a new shutdown procedure from being invoked. Apart from that the commands at the bottom of your batch file will never get issued since the loop will never end. You could to look at opening another console session using a defined windows title which runs the loop, running your commands in the original session ending with a command to close the looping batch using its windows title.

You may be able, as jaclaz already suggested, to simply rename shutdown.exe, (after preventing WFP from `fixing` it) but to be honest there's nothing to stop users from pushing the button on the front of the PC anyhow.

Also you say install process, what are you installing, it sounds as if you are trying to install something unattendedly for other users which must take some time and over which you'd like to have more control.

My suggestion, whether you like it or not, is to have a little faith in your end users, pop up a message letting them know of the install procedure and that switching off will likely render their computer useless.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...