Update 8x8_Work_Updater.ps1
This commit is contained in:
+18
-87
@@ -1,8 +1,8 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Script Name: 8x8_Work_Updater.ps1
|
# Script Name: 8x8_Work_Updater.ps1
|
||||||
# Description: Downloads 8x8 with a progress bar, pops up an interactive
|
# Description: Downloads 8x8 with a progress bar, triggers a native service
|
||||||
# unclosable countdown window (1-hour timer with "Update Now"),
|
# notification modal dialog on the user screen (bypasses non-interactive
|
||||||
# silently installs 8x8, and launches the updated client.
|
# Session 0 blocks), silently installs, and relaunches 8x8.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# Ensure script is running elevated
|
# Ensure script is running elevated
|
||||||
@@ -11,9 +11,8 @@ if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load required .NET assemblies
|
# Load required assemblies
|
||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
Add-Type -AssemblyName System.Drawing
|
|
||||||
Add-Type -AssemblyName System.Net.Http
|
Add-Type -AssemblyName System.Net.Http
|
||||||
|
|
||||||
$workDir = "C:\ProgramData\JCT600_8x8Update"
|
$workDir = "C:\ProgramData\JCT600_8x8Update"
|
||||||
@@ -64,90 +63,22 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Step 2: Show Interactive JCT600 Dialog Form
|
# Step 2: Show ServiceNotification Dialog (Crosses Session 0 Isolation)
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
Write-Host "[2/4] Displaying interactive countdown dialog..." -ForegroundColor Cyan
|
Write-Host "[2/4] Displaying interactive notification on user desktop..." -ForegroundColor Cyan
|
||||||
|
|
||||||
[System.Windows.Forms.Application]::EnableVisualStyles()
|
$title = "JCT600 IT Support — 8x8 Work Update"
|
||||||
|
$message = "An automatic update for 8x8 Work has been scheduled by IT Support.`n`nPlease save active work and wrap up ongoing calls.`n`nClick OK to proceed with the update."
|
||||||
|
|
||||||
$form = New-Object System.Windows.Forms.Form
|
# Use ServiceNotification flag to display onto the interactive desktop
|
||||||
$form.Text = "JCT600 IT Support — 8x8 Work Update"
|
[System.Windows.Forms.MessageBox]::Show(
|
||||||
$form.Size = New-Object System.Drawing.Size(460, 260)
|
$message,
|
||||||
$form.StartPosition = 'CenterScreen'
|
$title,
|
||||||
$form.FormBorderStyle = 'FixedDialog'
|
[System.Windows.Forms.MessageBoxButtons]::OK,
|
||||||
$form.MaximizeBox = $false
|
[System.Windows.Forms.MessageBoxIcon]::Information,
|
||||||
$form.MinimizeBox = $false
|
[System.Windows.Forms.MessageBoxDefaultButton]::Button1,
|
||||||
$form.ControlBox = $false
|
[System.Windows.Forms.MessageBoxOptions]::ServiceNotification
|
||||||
$form.TopMost = $true
|
) | Out-Null
|
||||||
|
|
||||||
$script:allowClose = $false
|
|
||||||
$form.Add_FormClosing({
|
|
||||||
param($sender, $e)
|
|
||||||
if (-not $script:allowClose) { $e.Cancel = $true }
|
|
||||||
})
|
|
||||||
|
|
||||||
$labelHeader = New-Object System.Windows.Forms.Label
|
|
||||||
$labelHeader.Text = "JCT600 — IT SUPPORT"
|
|
||||||
$labelHeader.Location = New-Object System.Drawing.Point(20, 15)
|
|
||||||
$labelHeader.Size = New-Object System.Drawing.Size(400, 25)
|
|
||||||
$labelHeader.Font = New-Object System.Drawing.Font("Segoe UI", 12, [System.Drawing.FontStyle]::Bold)
|
|
||||||
$labelHeader.ForeColor = [System.Drawing.Color]::Navy
|
|
||||||
$labelHeader.TextAlign = 'TopCenter'
|
|
||||||
$form.Controls.Add($labelHeader)
|
|
||||||
|
|
||||||
$labelMsg = New-Object System.Windows.Forms.Label
|
|
||||||
$labelMsg.Text = "An automatic update for 8x8 Work has been scheduled by IT Support.`nPlease save active work or click 'Update Now' to proceed."
|
|
||||||
$labelMsg.Location = New-Object System.Drawing.Point(20, 48)
|
|
||||||
$labelMsg.Size = New-Object System.Drawing.Size(400, 40)
|
|
||||||
$labelMsg.Font = New-Object System.Drawing.Font("Segoe UI", 9)
|
|
||||||
$labelMsg.TextAlign = 'TopCenter'
|
|
||||||
$form.Controls.Add($labelMsg)
|
|
||||||
|
|
||||||
$labelTimer = New-Object System.Windows.Forms.Label
|
|
||||||
$labelTimer.Location = New-Object System.Drawing.Point(20, 95)
|
|
||||||
$labelTimer.Size = New-Object System.Drawing.Size(400, 40)
|
|
||||||
$labelTimer.Font = New-Object System.Drawing.Font("Segoe UI", 20, [System.Drawing.FontStyle]::Bold)
|
|
||||||
$labelTimer.ForeColor = [System.Drawing.Color]::DarkRed
|
|
||||||
$labelTimer.TextAlign = 'MiddleCenter'
|
|
||||||
$form.Controls.Add($labelTimer)
|
|
||||||
|
|
||||||
$btnUpdateNow = New-Object System.Windows.Forms.Button
|
|
||||||
$btnUpdateNow.Text = "Update Now"
|
|
||||||
$btnUpdateNow.Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold)
|
|
||||||
$btnUpdateNow.Size = New-Object System.Drawing.Size(150, 40)
|
|
||||||
$btnUpdateNow.Location = New-Object System.Drawing.Point(145, 155)
|
|
||||||
$btnUpdateNow.UseVisualStyleBackColor = $true
|
|
||||||
|
|
||||||
$timer = New-Object System.Windows.Forms.Timer
|
|
||||||
$timer.Interval = 1000
|
|
||||||
$script:remaining = 3600 # 1 Hour
|
|
||||||
|
|
||||||
$btnUpdateNow.Add_Click({
|
|
||||||
$timer.Stop()
|
|
||||||
$script:allowClose = $true
|
|
||||||
$form.Close()
|
|
||||||
})
|
|
||||||
$form.Controls.Add($btnUpdateNow)
|
|
||||||
|
|
||||||
$timer.Add_Tick({
|
|
||||||
if ($script:remaining -gt 0) {
|
|
||||||
$timeSpan = [TimeSpan]::FromSeconds($script:remaining)
|
|
||||||
$labelTimer.Text = $timeSpan.ToString("hh\:mm\:ss")
|
|
||||||
$script:remaining--
|
|
||||||
} else {
|
|
||||||
$timer.Stop()
|
|
||||||
$script:allowClose = $true
|
|
||||||
$form.Close()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$initialSpan = [TimeSpan]::FromSeconds($script:remaining)
|
|
||||||
$labelTimer.Text = $initialSpan.ToString("hh\:mm\:ss")
|
|
||||||
|
|
||||||
$timer.Start()
|
|
||||||
$form.ShowDialog() | Out-Null
|
|
||||||
$timer.Dispose()
|
|
||||||
$form.Dispose()
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Step 3: Close Running 8x8 Processes & Install Silently
|
# Step 3: Close Running 8x8 Processes & Install Silently
|
||||||
@@ -190,7 +121,7 @@ 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) {
|
||||||
# Launching via explorer.exe ensures standard user execution token
|
# Using explorer.exe to launch the executable forces standard user graphics execution
|
||||||
Start-Process "explorer.exe" -ArgumentList "`"$exePath`""
|
Start-Process "explorer.exe" -ArgumentList "`"$exePath`""
|
||||||
Write-Host "8x8 Work launched successfully." -ForegroundColor Green
|
Write-Host "8x8 Work launched successfully." -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user