Shutdown Batch script

April 15, 2010 at 08:38:03
Specs: Windows XP

How can I prompt for an input when I click shutdown? and base on the input Yes or No, I will run different script file and shutdown the PC after running.


See More: Shutdown Batch script

Report •

April 15, 2010 at 09:30:33

Are the computers on a Domain?

I would just make a logoff batch file and assign it to their GPO. It will fire when they do a shutdown.

Even if it is not a part of a domain you can still do a GPEDIT.MSC and go to the Computer Configuration -> Windows Settings -> Scripts and set the batch file in the Logoff Script.

As for how to write the script read...

I have to look at it but there might have been a run script on shutdown in the group policies. I will look for it. It could have been my imagination. There is so much you can do in the group policies.

Report •

April 15, 2010 at 12:18:33

You don't say whether you are using XP Home or XP Professional. Note that GPEDIT.MSC does not apply to XP Home.

What's the time?

Report •

April 22, 2010 at 08:21:02

Thanks for your prompt reply.
Am i able to prompt for the user input using radio buttons and based on the selection run diff batch files?


Report •

Related Solutions

April 22, 2010 at 10:48:37

If you want a GUI then you will need to write a Windows App. Do you have any programming experience? If not then you might have to seek out a programmer.

Report •

April 22, 2010 at 10:59:07

I think this must be possible somehow, maybe even with batch files. I only wish I knew enough to be able to help. However, just to show the sort of things you can do here is an example of my shutdown batch file:

@echo off
START /W /MIN sc config Wuauserv start= demand
START /W /MIN net stop "Automatic Updates"
START /W /MIN C:\Progra~1\Clearers\Genera~1.bat
START /W /MIN C:\Progra~1\CCleaner\ccleaner.exe /AUTO
del /q "c:\micrografx has run.txt"
START /MIN c:\Windows\system32\shutdown.exe -s -t 00

What the above does is:
1. Switch the Auto Updates Service to Manual.
2. Stop Auto Updates Service from running
3. Run a clean-up batch file (Genera~1.bat)
4. Run CCleaner (ccleaner.exe /AUTO)
5. Delete a text file (micrografx has run.txt)
6. Shut down the system (last line).

I appreciate that only number 6 is of any interest but the above does show that you can apply many tricks before shut-down. There is defintely a way to get Yes / No actions in batch files but I've never had need to do so. See here:
Note that the "choice" command is not part of XP (old W98 command) although the choice.exe file can be downloaded and run from c:windows\system32. The XP version is "Set", see here:

Maybe someone will eventually pop along who can help with the detail. Visiting some Batch File forums or information websites might help. It's a pity you didn't put this in the Programming forum but it's too late now because double posting is against the forum rules - well, maybe you'll get away with it if you wait a long time and then reword.

I trust that the foregoing at least gives you some "hope" and perhaps some ideas. Have fun!

What's the time?

Report •

April 23, 2010 at 05:25:01

My experience is that when using GPEDIT for using scripts for shutdown, the scripts run, but they are not visible for you to see. This would mean that user input is not an option ...

Report •

April 23, 2010 at 08:19:42

I still think IP reservation would still work better you might want to look into them.

Report •

April 30, 2010 at 08:39:57

The information is extremely helpful and I have manged to write a batch file which prompt for Y/N and run different scripts based on the input.

However, when I tried to put the batch file in my window shutdown script, it did not prompt for Y/N. is there a way to show up the prompt?

Thanks again for your advice.

Report •

April 30, 2010 at 14:41:02

I don't know enough about this to properly help but it sounds like you might be starting the shutdown process before the Y/N prompt has had time to appear and be actioned.

Obviously the "shutdown" has to be the last command. Assuming this is the case you might have to put START /W at the beginning of the process line before the shutdown command. This means that it does not move on (to shutdown) until that part has completed - the W is "wait".

You might be better off to post the script on the Programming forum (with a brief explanation of what it is intended to do). With luck someone will come along who is much better at the detail than I am.

What's the time?

Report •

Ask Question