From 3c2b236d0a21186bcff3bc69550b12d8d87c8ee5 Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Sat, 11 May 2024 20:53:18 +0000 Subject: [PATCH] Compile Winutil --- winutil.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/winutil.ps1 b/winutil.ps1 index 13daae3e..66f21eb2 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -13864,10 +13864,14 @@ Add-Type @" "@ } - foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) { - if ($proc.Id -ne [System.IntPtr]::Zero) { + foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) { + # Check if the process's MainWindowHandle is valid + if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) { Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)" $windowHandle = $proc.MainWindowHandle + } else { + Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)" + } }