Find my own process ID in VBScript

后端 未结 10 1052
小蘑菇
小蘑菇 2020-11-28 14:49

I\'m using the following code snippet to determine what process ID my vbscript is running as:

On Error Resume Next
Dim iMyPID : iMyPID = GetObject(\"winmgmts         


        
10条回答
  •  孤街浪徒
    2020-11-28 15:12

    You may use Sleep from kernel32 instead of mshta.

    MsgBox GetProcId()
    
    Function GetProcId()
        With GetObject("winmgmts:\\.\root\CIMV2:Win32_Process.Handle='" & CreateObject("WScript.Shell").Exec("rundll32 kernel32,Sleep").ProcessId & "'")
            GetProcId = .ParentProcessId
            .Terminate
        End With
    End Function
    

    Code taken from here.

    Also there is parent process name detection based on this approach.

提交回复
热议问题