想要编写 Windows WMI (wmiprvse.exe) 脚本以释放文件句柄 [英] Want to script Windows WMI (wmiprvse.exe) to release handle on file

查看:58
本文介绍了想要编写 Windows WMI (wmiprvse.exe) 脚本以释放文件句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用其他人编写的 VB 脚本文件,该文件使用 Windows 管理规范 (WMI) 调用来检查多个 Windows 服务的状态.此脚本按设定的时间表每隔几分钟运行一次.我需要升级/替换这些服务的 .exe.

I'm working with a VB Script file written by someone else that uses Windows Management Instrumentation (WMI) calls to check on the status of several Windows Services. This script runs every few minutes on set schedule. I need to upgrade/replace the .exe for those services.

我停止了 VB 脚本,停止了服务,然后卸载了服务,这样它们就不再出现在服务面板 (services.msc) 中.不幸的是,WMI (wmiprvse.exe) 仍然可以处理服务 .exe 文件.我可以通过重新启动系统来释放句柄,但我想尽可能避免这种情况,因此这可以是完全脚本化/自动化的升级.

I stop the VB Script, stop the services, and uninstall the services so they no longer appear in the Services panel (services.msc). Unfortunately, WMI (wmiprvse.exe) still has a handle on the service .exe files. I can release the handle by rebooting the system, but I want to avoid that if at all possible so this can be a completely scripted/automated upgrade.

有没有办法强制 WMI 释放它在 .exe 上的句柄?请记住,我是 WMI 的新手.

Is there a way I can force WMI to release it's handle on the .exe? Please keep in mind I'm new to working with WMI.

推荐答案

我也在寻找这个问题的解决方案.还想了解为什么 wmiprsve 可以处理我的某些服务可执行文件,而不能处理其他服务.

I'm also looking for a solution to this problem. Would also like to understand why wmiprsve has handles on some of my service executables but not on others.

我使用的解决方法是终止 wmiprvse 进程.您可以使用 SysInternals 命令行工具(pslist、pskill)来自动获取进程 ID 并执行终止操作.

The workaround I'm using is to kill the wmiprvse process. You can use the SysInternals command line tools (pslist, pskill) to automate getting the process id and performing the kill.

这篇关于想要编写 Windows WMI (wmiprvse.exe) 脚本以释放文件句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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