This link discusses how a shutdown hook can be implemented using VB. Now my question is, can something like that be done using Windows Script Host/windows scripting host?
I would very much appreciate your input; maybe include some code snippets.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not sure about other scripting languages such as PowerShell or Perl, but in VBScript/JScript there doesn’t seem a way to do this.
First of all, Windows Script Host doesn’t provide access to Windows API so you can’t intercept the
WM_ENDSESSIONandWM_QUERYENDSESSIONWindows messages (as suggested in the article you mentioned) from VBScript/JScript.There’s the WMI
Win32_ComputerShutdownEventevent though, which occurs when a computer shuts down, but you can only receive this event from remove computers. When the local computer shuts down, the script is terminated before the event is delivered.