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