79457852

Date: 2025-02-21 15:29:19
Score: 1
Natty:
Report link

don't overengineer it :-)

getOwnProcessId = getObject("winmgmts:\.\root\cimv2").ExecQuery("Select * From Win32_Process Where ProcessId=" & createObject("wscript.shell").Exec("rundll32").ProcessID).itemIndex(0).ParentProcessId

if oWShell and oWMI is already defined in your script:

getOwnProcessId = oWMI.ExecQuery("Select * From Win32_Process Where ProcessId=" & oWShell("rundll32").ProcessID).itemIndex(0).ParentProcessId

No need to actively terminate your temporarily created child-process:

rundll32 just terminates if called without parameter, but the exec-object is still properly initiated with the parentId information

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Michael Frei