How can I use Handle.exe with Windows PowerShell

Occasional Visitor

Nobody is helping and I can't solve this problem. I want to remove any that has a handle on Notepad.exe. I know how to run sysinternal handle.exe in this url source. But I am coding a software and I want to execute an automatic code with powershell and do it with a single code. https://docs.microsoft.com/tr-tr/sysinternals/downloads/handle How can I close a handle I want with Windows Sysinternals Handle v4.22? Example: Notepad.exe > Handles > C:\Users\dream > Close > Happy end

 

I want to close all C:\Users\dream handles open on Notepad.exe.

But I want to do this using the handle.exe via powershell. How can I do this with a single code? Please help. :(

 

v1.png

1 Reply

@dreamfancy 

From what I try to understand, you are trying to get the executed command (command id) from a process and perform an action against it, such as a notepad open a file called C:\users\dream, you want to close the notepad.

if so, you can use the WMI Object

Get-WmiObject Win32_Process | select name, commandline