Link to home
Start Free TrialLog in
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 ??
Avatar of Badotz
Badotz
Flag of United States of America image

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
Avatar of DAWR
DAWR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dendob
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

correction on my behalf, its shutdown -a :)
nova-c can you please comment on having your problem solved? or do you need help implementing the script?

Kind Regards