简体   繁体   中英

Get Process Handle in PowerShell

I am trying to get a process handle without success, I have read a lot about that but don't know why I cannot achieve it.

This is what I am doing:

在此处输入图片说明

$handle = $Kernel32::OpenProcess(PROCESS_ALL_ACCESS, FALSE, 4548)

I am doing it with admin rights, it seems like it doesn't like the PROCESS_ALL_ACCESS parameter. Any idea?

PowerShell doesn't recognize the symbolic constants you're trying to use there. Use the numeric values instead. For PROCESS_ALL_ACCESS that should be 1056763 or 0x00101ffb (and you also need $false instead of FALSE ). However, you probably shouldn't be using PROCESS_ALL_ACCESS in the first place.

Try with PROCESS_QUERY_LIMITED_INFORMATION (numeric value 4096 or 0x1000):

$handle = $Kernel32::OpenProcess(0x1000, $false, 4548)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM