【发布时间】:2017-07-07 05:25:12
【问题描述】:
为什么以下 VBS 代码在 Windows 7 中可以工作,但在 Windows 10 上却报错:
strComputer="."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'notepad.exe'")
Wscript.Echo colProcesses.Count
我在 Windows 10 中遇到的错误是:
test_2.vbs(4,1) SWbemObjectSet:无效查询
我在这里做错了什么?
【问题讨论】:
-
您的代码在我的系统上运行良好(不过使用 Win 7)。
-
是的,正如我在我的问题中提到的,它适用于 Windows 7,但不适用于 Windows 10
-
哦..我没注意到:P