Update 8x8_Work_Updater.ps1
This commit is contained in:
+18
-1
@@ -83,6 +83,14 @@ try {
|
|||||||
Write-Host "[2/5] Generating user-session GUI dialog script..." -ForegroundColor Cyan
|
Write-Host "[2/5] Generating user-session GUI dialog script..." -ForegroundColor Cyan
|
||||||
|
|
||||||
$guiContent = @'
|
$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.Windows.Forms
|
||||||
Add-Type -AssemblyName System.Drawing
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
|
||||||
@@ -195,7 +203,16 @@ $form.Dispose()
|
|||||||
if (-not $explorerProc) {
|
if (-not $explorerProc) {
|
||||||
Write-Warning "No active desktop session detected. Proceeding directly to update."
|
Write-Warning "No active desktop session detected. Proceeding directly to update."
|
||||||
} else {
|
} 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
|
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 displayed on user screen. Waiting for response or 1-hour expiration..." -ForegroundColor Yellow
|
||||||
|
|||||||
Reference in New Issue
Block a user