diff --git a/8x8_Work_Updater.ps1 b/8x8_Work_Updater.ps1 index 144393b..5772aae 100644 --- a/8x8_Work_Updater.ps1 +++ b/8x8_Work_Updater.ps1 @@ -83,6 +83,14 @@ try { Write-Host "[2/5] Generating user-session GUI dialog script..." -ForegroundColor Cyan $guiContent = @' +# Hide PowerShell console window host immediately while rendering WinForms +$async = '[DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);' +$type = Add-Type -MemberDefinition $async -Name "Win32ShowWindow" -Namespace Win32Functions -PassThru +$hwnd = (Get-Process -Id $PID).MainWindowHandle +if ($hwnd -ne [IntPtr]::Zero) { + [Win32Functions.Win32ShowWindow]::ShowWindow($hwnd, 0) +} + Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing @@ -195,7 +203,16 @@ $form.Dispose() if (-not $explorerProc) { Write-Warning "No active desktop session detected. Proceeding directly to update." } else { - $serviceUiArgs = "-process:explorer.exe powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$guiScript`"" + # Explicit ServiceUI argument syntax targeting powershell.exe without hiding the Form + $psExe = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" + $serviceUiArgs = @( + "-process:explorer.exe", + $psExe, + "-NoProfile", + "-ExecutionPolicy", "Bypass", + "-File", "`"$guiScript`"" + ) -join " " + Start-Process -FilePath $serviceUiPath -ArgumentList $serviceUiArgs Write-Host "Dialog displayed on user screen. Waiting for response or 1-hour expiration..." -ForegroundColor Yellow