在VBS脚本中,根据进程的名称获取进程的ID
GetPID("bla.exe")
function GetPID(name)
set WMI = GetObject("winmgmts:\\.\root\cimv2")
set TaskList = WMI.ExecQuery _
("Select * from Win32_Process Where Name = '" & name & "'")
for each x in TaskList
PID = x.ProcessId
next
if IsEmpty(PID) then
PID = false
end if
GetPID = PID
end function
// 例子
function OpenPID(PID)
set WS = CreateObject("Wscript.Shell")
WS.AppActivate PID
end function