如何使用 VBS 关闭/终止/终止应用程序实例? [英] How to close/terminate/kill an instance of a application with VBS?

查看:130
本文介绍了如何使用 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

<小时>

一些链接:

这篇关于如何使用 VBS 关闭/终止/终止应用程序实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆