VBS 获取当前进程 ID

Function CurrProcessId
Dim oShell, sCmd, oWMI, oChldPrcs, oCols, lOut
lOut =
Set oShell = CreateObject("WScript.Shell")
Set oWMI = GetObject(_
"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
sCmd = "/K " & Left(CreateObject("Scriptlet.TypeLib").Guid, )
oShell.Run "%comspec% " & sCmd, rem WScript.Sleep 100 'For healthier skin, get some sleep
Set oChldPrcs = oWMI.ExecQuery("Select * From Win32_Process Where CommandLine Like '%" & sCmd & "'",,)
For Each oCols In oChldPrcs
lOut = oCols.ParentProcessId
oCols.Terminate
Exit For
Next
CurrProcessId = lOut
End Function msgbox CurrProcessId
上一篇:Java基础语法面试题50题整理(带答案)


下一篇:手机APP应用外网访问本地WEB应用