Any way to get the PID of a child process from a CMD.exe PID?
Any way to get the PID of a child process from a CMD.exe PID?
If i have the PID of a CMD.exe running on the system. Is there a way to find the PID of the process that runs inside that CLI box ?
Re: Any way to get the PID of a child process from a CMD.exe PID?
If you can attach to the cmd.exe console:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
scriptPID := DllCall("GetCurrentProcessId", "UInt")
Process, Exist, cmd.exe
targetCmdPID := ErrorLevel
if (targetCmdPID && DllCall("AttachConsole", "UInt", targetCmdPID)) {
processCount := 10
Loop {
VarSetCapacity(processList, processCount * 4, 0)
actualCapacity := DllCall("GetConsoleProcessList", "Ptr", &processList, "UInt", processCount, "UInt") ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683170(v=vs.85).aspx
if (!actualCapacity) {
break
} else if (actualCapacity > processCount) {
processCount := actualCapacity
continue
}
Loop %actualCapacity% {
dwPID := NumGet(processList, (A_Index - 1) * 4, "UInt")
if (dwPID == scriptPID || dwPID == targetCmdPID)
continue
MsgBox % dwPID
}
break
}
DllCall("FreeConsole")
}
Who is online
Users browsing this forum: No registered users and 336 guests