From a10971e62e085cdbc1892a22143daa46eabc4fca Mon Sep 17 00:00:00 2001 From: CristianD Date: Mon, 24 Aug 2026 15:15:11 +0100 Subject: [PATCH] Update 8x8_Work_Updater.ps1 --- 8x8_Work_Updater.ps1 | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/8x8_Work_Updater.ps1 b/8x8_Work_Updater.ps1 index 5772aae..5ae71bf 100644 --- a/8x8_Work_Updater.ps1 +++ b/8x8_Work_Updater.ps1 @@ -18,6 +18,7 @@ $flagFile = Join-Path $workDir "8x8_Update_Proceed.flag" $guiScript = Join-Path $workDir "Show-8x8UserGui.ps1" $serviceUiPath = Join-Path $workDir "ServiceUI.exe" $installerPath = Join-Path $workDir "8x8_Work_Installer.msi" +$serviceUiLog = Join-Path $workDir "ServiceUI.log" if (-not (Test-Path $workDir)) { New-Item -Path $workDir -ItemType Directory -Force | Out-Null @@ -83,14 +84,6 @@ 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 @@ -203,19 +196,12 @@ $form.Dispose() if (-not $explorerProc) { Write-Warning "No active desktop session detected. Proceeding directly to update." } else { - # 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 " " + + # Execute ServiceUI directly with distinct parameters + $process = Start-Process -FilePath $serviceUiPath -ArgumentList "-process:explorer.exe", $psExe, "-ExecutionPolicy", "Bypass", "-NoProfile", "-WindowStyle", "Hidden", "-File", "`"$guiScript`"" -PassThru - Start-Process -FilePath $serviceUiPath -ArgumentList $serviceUiArgs - - Write-Host "Dialog displayed on user screen. Waiting for response or 1-hour expiration..." -ForegroundColor Yellow + Write-Host "Dialog launched. Waiting for user response or 1-hour expiration..." -ForegroundColor Yellow while (-not (Test-Path $flagFile)) { Start-Sleep -Seconds 2 } @@ -263,8 +249,7 @@ $form.Dispose() if ($exePath) { if ($explorerProc) { - $launchArgs = "-process:explorer.exe `"$exePath`"" - Start-Process -FilePath $serviceUiPath -ArgumentList $launchArgs + Start-Process -FilePath $serviceUiPath -ArgumentList "-process:explorer.exe", "`"$exePath`"" Write-Host "8x8 Work launched successfully in user context." -ForegroundColor Green } else { Start-Process -FilePath $exePath