开发者

Shutdown Hook with windows-scripting-host

This link discusses how a shutdown hook can be implemented using VB. No开发者_如何学Pythonw 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜