带 windows-scripting-host 的关闭挂钩

发布于 2024-09-13 19:26:19 字数 202 浏览 2 评论 0原文

链接讨论了如何使用 VB 实现关闭挂钩。现在我的问题是,可以使用 Windows 脚本主机/Windows 脚本主机来完成类似的事情吗?

我非常感谢您的意见;也许包括一些代码片段。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿咻 2024-09-20 19:26:19

不确定其他脚本语言(例如 PowerShell 或 Perl),但在 VBScript/JScript 中似乎没有办法做到这一点。

首先,Windows Script Host 不提供对 Windows API 的访问,因此您无法拦截 WM_ENDSESSIONWM_QUERYENDSESSION Windows 消息(如您​​提到的文章中所建议的)来自 VBScript/JScript。

不过,有 WMI Win32_ComputerShutdownEvent 事件,当计算机关闭时发生这种情况,但是 您只能从已删除的计算机接收此事件。当本地计算机关闭时,脚本会在事件传递之前终止。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文