Avatar of Nova Consult ApS
Nova Consult ApS asked on

cancel shutdown in logoff script

I need a script that ask a user "did you remember to make your local backup) Y/N and if the user say no i'll like it to stop the computer shutdown is that poisble ??
Scripting LanguagesVB Script

Avatar of undefined
Last Comment
dendob

8/22/2022 - Mon
Badotz

Using JavaScript, I do this:

function lastChance()
{
      return "Did you remember to make your local backup?";
}


window.onbeforeunload = lastChance;

VBScript would look similar, I suppose (not tested):

Function lastChance()

      lastChance =  "Did you remember to make your local backup?"
End Function


window.onbeforeunload = lastChance

Either example would go in a <script></script> block in the HEAD section of your page.
ASKER CERTIFIED SOLUTION
DAWR

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dendob

its even easier:

this is small bat file:

thats all there is to it

Paste this into a bat file, when the user answers no (choice 2)
the computer will shutdown

If in use by a domain, you can get this script to run by the domain policy as logoff script

If you want it for a single computer:
Start "Local Computer Policy" using the MMC console. Expand User configuration, expand Windows Settings and click Scripts (Logon/Logoff) and add the script you want to run when logging off.
@ECHO OFF
choice /m "Have you backup today?"
IF ERRORLEVEL 2 GOTO two
IF ERRORLEVEL 1 GOTO one
 
:one
echo shutdown continues as normal
GOTO END
 
:two
shutdown -c
echo shutdown canceled
GOTO END
 
:END
pause

Open in new window

dendob

correction on my behalf, its shutdown -a :)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
dendob

nova-c can you please comment on having your problem solved? or do you need help implementing the script?

Kind Regards