如何使用 VBS 关闭/终止/终止应用程序实例? [英] How to close/terminate/kill an instance of a application with VBS?
问题描述
如何使用 VBS 关闭/终止/终止应用程序的实例?
How to close/terminate/kill an instance of a application with VBS?
我已经尝试了以下代码,在几个帖子中都提出了建议,但没有奏效.
I've tried the following code, suggested on several posts, and it didn´t work.
Set x = GetObject(,"xxx.Application")
x.quit
推荐答案
我想我曾经使用过 WMI,而且效果很好 - 前提是脚本运行时具有杀死有问题的进程(换句话说,系统进程的管理员权限,用户上下文进程的用户权限 - 我想可能有 NT 权限/NT 权限(系统范围的权限)和自定义 ACL 权限设置(访问控制列表 - 附加到对象)也涉及 - 其配置可能因站点而异):
I think I used WMI at one point, and that worked OK - provided the script runs with the access rights required to kill the processes in question (in other words admin rights for system processes, user rights for user context processes - I suppose there could be NT Privileges / NT Rights (system wide privileges) and custom ACL permission settings (access control list - attached to objects) involved as well - the configuration of which might vary from site to site):
注意: 下面的脚本将杀死所有 Notepad.exe 进程!(除非访问被拒绝)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
<小时>
一些链接:
- 使用 VBScript 关闭应用程序(其他几个选项)
- 杀死显示拒绝访问"的进程(auperuser - 终止进程 ACL)
- 不可杀死的进程
这篇关于如何使用 VBS 关闭/终止/终止应用程序实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!