1.

Solve : Batch Files executing at shutdown?

Answer»

I am looking to execute a batch file that I have created, but I do need it to execute in a special way:

Once a user clicks on Shutdown to turn off their computer, a windows message will pop up SAYING "Have you Clocked Out?" If the user selects "YES" then windows will CONTINUE to shutdown. If the user clicks "NO", windows will open the a program/webpage so that users can clock out before shutting down windows. Does anyone know how to do this?
try this
@echo off
cls
:start
echo Have you clocked out
ECHO.
ECHO 1. YES
ECHO 2. NO
set choice=
set /p choice=Select a choice=
if '%choice%'=='1' goto 1
if '%choice%'=='2' goto 2
ECHO "%choice%" please choose one of the choices above
ECHO.
goto start
:1
(something goes here, but i dont know)
:2
start=program/webpage
exit

Code: [Select]@echo off
:start
echo Have you clocked out?
ECHO.
ECHO 1. YES
ECHO 2. NO
set choice=
set /p choice=Select a choice=
if '%choice%'=='1' goto 1
if '%choice%'=='2' goto 2
ECHO Please choose one of the choices above
ECHO.
goto start
:1
shutdown -f -t 00 -s
goto end
:2
start program/webpage
:end

I think that works. I just made a modification on Amrykid's code.Thanks Dark Blade, im a begginner at DOS and command prompt.No problem. You were pretty close, though, you just didn't add shutdown, and forgot a goto. Other than that, it was quite good
But the way I read the first post, the original poster does not need any batch code.

Quote from: rcapulong on July 03, 2007, 10:44:28 AM

I am looking to execute a batch file that I have created,



What he needs is for you to tell him how to get his batch file to run at the time he needs it run:

Quote
but I do need it to execute in a special way:

Once a user clicks on Shutdown to turn off their computer, ...

.... Does anyone know how to do this?

This is strange. I presume "clocked out" means "logged out". When somebody with sufficient privileges initiates a shutdown, all users are logged out automatically.

However, to run a script or batch at shutdown. select Start | Run and type gpedit.msc, then click OK; then look in Computer | Configuration | Windows Settings | Scripts (Startup/Shutdown). Double click Shutdown in the right-hand pane, then click Add to add one or more scripts as needed.
Is it me, or will the code posted previously not WORK because choice was replaced in Win XP. That is if he's running Win XP.Quote from: Jake1234 on July 04, 2007, 01:31:19 PM
Is it me, or will the code posted previously not work because choice

as in choice.com ?

Quote
was replaced in Win XP. That is if he's running Win XP.

choice.com is not being used in the batch FILES above.



Side note, just in case anyone is USING Search and stumbles across this thread: If you need a copy of choice , here is one place to visit.
>Click here<
Quote from: Jake1234 on July 04, 2007, 01:31:19 PM
Is it me, or will the code posted previously not work because choice was replaced in Win XP. That is if he's running Win XP.

a variable called "choice" is being used, but neither choice.com nor choice.exe is being called.



Discussion

No Comment Found