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
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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

Avatar of dendob
dendob

correction on my behalf, its shutdown -a :)
Avatar of dendob
dendob

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

Kind Regards
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo