Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
- $sig = @"
- [DllImport("user32.dll", SetLastError=true)]
- public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
- "@
- Add-Type -MemberDefinition $sig -Namespace User32 -Name Util -UsingNamespace System.Text
- $p=0
- [User32.util]::GetWindowThreadProcessId($MSExcel.HWND, [ref]$p) |out-null
- Get-Process -id $p | Stop-Process
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement