Update 8x8_Work_Updater.ps1
This commit is contained in:
+21
-16
@@ -1,8 +1,8 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Script Name: 8x8_Work_Updater.ps1
|
# Script Name: 8x8_Work_Updater.ps1
|
||||||
# Description: Downloads 8x8, pops up a native interactive alert directly into
|
# Description: Downloads 8x8 with a progress bar, triggers a blocking 1-hour
|
||||||
# the active user session, waits for 1 hour or immediate click,
|
# popup alert, silently installs, and launches 8x8 under the standard
|
||||||
# silently installs, and relaunches 8x8.
|
# user session via Explorer.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# Ensure script is running elevated
|
# Ensure script is running elevated
|
||||||
@@ -11,10 +11,12 @@ if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Load required .NET assemblies
|
||||||
Add-Type -AssemblyName System.Net.Http
|
Add-Type -AssemblyName System.Net.Http
|
||||||
|
|
||||||
$workDir = "C:\ProgramData\JCT600_8x8Update"
|
$workDir = "C:\ProgramData\JCT600_8x8Update"
|
||||||
$installerPath = Join-Path $workDir "8x8_Work_Installer.msi"
|
$installerPath = Join-Path $workDir "8x8_Work_Installer.msi"
|
||||||
|
$vbsAlertPath = Join-Path $workDir "ShowUserAlert.vbs"
|
||||||
|
|
||||||
if (-not (Test-Path $workDir)) {
|
if (-not (Test-Path $workDir)) {
|
||||||
New-Item -Path $workDir -ItemType Directory -Force | Out-Null
|
New-Item -Path $workDir -ItemType Directory -Force | Out-Null
|
||||||
@@ -62,20 +64,21 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Step 2: Native Interactive Session Alert (Crosses Session 0 Isolation)
|
# Step 2: Trigger Blocking Interactive Popup (Waits for Click or 1 Hour)
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
Write-Host "[2/4] Triggering interactive alert on active user's desktop..." -ForegroundColor Cyan
|
Write-Host "[2/4] Triggering interactive alert on active user's desktop..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# Detect Active User Session ID (query session / qwinsta)
|
# Generate a blocking VBScript WshShell.Popup (Type 48 = Exclamation, 4096 = System Modal / Always on top)
|
||||||
$activeSession = (query session | Select-String "Active") -replace '\s+', ' '
|
$vbsContent = @"
|
||||||
$sessionId = if ($activeSession) { ($activeSession.ToString().Trim().Split(' '))[2] } else { 1 }
|
Set wshShell = CreateObject("WScript.Shell")
|
||||||
|
intButton = wshShell.Popup("An automatic update for 8x8 Work has been scheduled by JCT600 IT Support." & vbCrLf & vbCrLf & "Please save active work and finish ongoing calls." & vbCrLf & vbCrLf & "Click OK or close this window to update immediately, or wait for the 1-hour timer.", 3600, "JCT600 IT Support — 8x8 Work Update", 48 + 4096)
|
||||||
|
"@
|
||||||
|
|
||||||
# Send native interactive dialog directly to user's active screen
|
[System.IO.File]::WriteAllText($vbsAlertPath, $vbsContent, [System.Text.Encoding]::ASCII)
|
||||||
$title = "JCT600 IT Support - 8x8 Work Update"
|
|
||||||
$message = "An automatic update for 8x8 Work has been scheduled by IT Support.`n`nPlease save your active work and wrap up ongoing calls.`n`nThe update will process automatically in 60 minutes."
|
|
||||||
|
|
||||||
# msg.exe sends notification floating on user session screen
|
# Launch popup and WAIT for user click or 3600-second timeout
|
||||||
msg.exe $sessionId /TIME:3600 "$title`n`n$message"
|
Write-Host "Waiting for user acknowledgment or 1-hour timeout..." -ForegroundColor Yellow
|
||||||
|
$popupProcess = Start-Process "wscript.exe" -ArgumentList "`"$vbsAlertPath`"" -Wait -PassThru
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Step 3: Close Running 8x8 Processes & Install Silently
|
# Step 3: Close Running 8x8 Processes & Install Silently
|
||||||
@@ -104,9 +107,9 @@ try {
|
|||||||
Write-Host "Installation completed successfully." -ForegroundColor Green
|
Write-Host "Installation completed successfully." -ForegroundColor Green
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Step 4: Launch 8x8 Work
|
# Step 4: Launch 8x8 Work via Explorer (User Context)
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
Write-Host "[4/4] Launching 8x8 Work..." -ForegroundColor Cyan
|
Write-Host "[4/4] Launching 8x8 Work in user session..." -ForegroundColor Cyan
|
||||||
|
|
||||||
$possiblePaths = @(
|
$possiblePaths = @(
|
||||||
"${env:ProgramFiles}\8x8 Inc\8x8 Work\8x8 Work.exe",
|
"${env:ProgramFiles}\8x8 Inc\8x8 Work\8x8 Work.exe",
|
||||||
@@ -118,7 +121,9 @@ try {
|
|||||||
$exePath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
$exePath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
|
|
||||||
if ($exePath) {
|
if ($exePath) {
|
||||||
Start-Process -FilePath $exePath
|
# Using explorer.exe to launch the executable forces Windows to run 8x8 in
|
||||||
|
# the interactive standard user's desktop context, preventing GPU crashes.
|
||||||
|
Start-Process "explorer.exe" -ArgumentList "`"$exePath`""
|
||||||
Write-Host "8x8 Work launched successfully." -ForegroundColor Green
|
Write-Host "8x8 Work launched successfully." -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
Write-Warning "Could not locate 8x8 Work executable."
|
Write-Warning "Could not locate 8x8 Work executable."
|
||||||
|
|||||||
Reference in New Issue
Block a user