我有下面的 vbs 脚本,它应该接受一个进程名(例如 Notepad.exe),然后报告与该名称匹配的所有进程的相关详细信息。
它在我的电脑(win 7)上运行良好,但在我的服务器(Windows 2000)上我收到一条错误消息"Object doesn't support this property or method: objProcess.commandLine"
(第 30 行)
我假设它与 Windows 2000 有关,因为我让它在 Windows 2008 上运行正常。有什么我需要安装/更改才能使其工作的吗?
Option Explicit
dim strComputer
dim objWMIService
dim colProcessList
dim objProcess
dim PName
dim PCommandLine
dim PCLSplit
dim input
dim counter
input = InputBox("Please Enter the Process Name, as shown in Task Manager", "Enter Process Name", , 100, 200)
If input = "" Then
WScript.Echo "Canceled"
Else
WScript.Echo "You Entered: " & input
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & input & "'")
counter = 1
For Each objProcess in colProcessList
Wscript.echo counter & ")"
PName = objProcess.Name
PCommandLine = objProcess.CommandLine
PCLSplit = SPLIT(PCommandLine,chr(34))
Wscript.Echo "Application Name: " & PName & VbCrLf &_
"Command Line: " & PCLSplit(1) & VbCrLf &_
"Instance Name: " & PCLSplit(2) & VbCrLf
counter = 1+1
Next
wscript.echo "COMPLETE"
End If
wscript.quit