Update 8x8_Work_Updater.ps1
This commit is contained in:
+5
-20
@@ -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 " "
|
||||
|
||||
Start-Process -FilePath $serviceUiPath -ArgumentList $serviceUiArgs
|
||||
# Execute ServiceUI directly with distinct parameters
|
||||
$process = Start-Process -FilePath $serviceUiPath -ArgumentList "-process:explorer.exe", $psExe, "-ExecutionPolicy", "Bypass", "-NoProfile", "-WindowStyle", "Hidden", "-File", "`"$guiScript`"" -PassThru
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user