views:

21

answers:

1

Hi,

The following link (http://www.bigresource.com/Tracker/Track-vb-MjQNB6lXIl/) 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.

Thanks, Klaus.

A: 

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_ENDSESSION and WM_QUERYENDSESSION Windows messages (as suggested in the article you mentioned) from VBScript/JScript.

There's the WMI Win32_ComputerShutdownEvent event 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.

Helen