Update 8x8_Work_Updater.ps1

This commit is contained in:
2026-08-25 08:26:56 +01:00
parent da43fcc032
commit fedd15d702
+21 -21
View File
@@ -1,8 +1,8 @@
# ==============================================================================
# Script Name: 8x8_Work_Updater.ps1
# Description: Downloads 8x8 with a progress bar, launches an unclosable HTA
# countdown prompt in the user's session (no X button), waits for
# user action or 1-hour timeout, installs silently, and relaunches 8x8.
# countdown prompt with real-clock wall-time tracking (sleep-safe),
# silently installs, and relaunches 8x8 Work.
# ==============================================================================
# Ensure script is running elevated
@@ -70,15 +70,15 @@ try {
}
# --------------------------------------------------------------------------
# Step 2: Generate Unclosable HTA Countdown Dialog (No Close/X Button)
# Step 2: Generate Sleep-Safe Wall-Clock HTA Countdown Dialog
# --------------------------------------------------------------------------
Write-Host "[2/4] Generating unclosable dialog..." -ForegroundColor Cyan
Write-Host "[2/4] Generating sleep-safe unclosable dialog..." -ForegroundColor Cyan
$htaContent = @"
<!DOCTYPE html>
<html>
<head>
<title>JCT600 IT Support - 8x8 Work Update</title>
<title>JCT600 IT Support 8x8 Work Update</title>
<HTA:APPLICATION
ID="o8x8Update"
APPLICATIONNAME="JCT600 8x8 Work Update"
@@ -142,32 +142,32 @@ try {
}
</style>
<script language="javascript">
var totalSeconds = 3600;
// Target end time: exactly 1 hour from initial load (survives sleep/standby mode)
var targetTime = new Date().getTime() + (3600 * 1000);
function initWindow() {
window.resizeTo(480, 270);
window.moveTo((screen.width - 480) / 2, (screen.height - 270) / 2);
updateDisplay();
tick();
setInterval(tick, 1000);
}
function tick() {
var now = new Date().getTime();
var remainingMilliseconds = targetTime - now;
var totalSeconds = Math.floor(remainingMilliseconds / 1000);
if (totalSeconds > 0) {
totalSeconds--;
updateDisplay();
var mins = Math.floor(totalSeconds / 60);
var secs = totalSeconds % 60;
var formattedMins = mins < 10 ? "0" + mins : mins;
var formattedSecs = secs < 10 ? "0" + secs : secs;
document.getElementById("timerDisplay").innerText = formattedMins + ":" + formattedSecs;
} else {
proceedUpdate();
}
}
function updateDisplay() {
var mins = Math.floor(totalSeconds / 60);
var secs = totalSeconds % 60;
var formattedMins = mins < 10 ? "0" + mins : mins;
var formattedSecs = secs < 10 ? "0" + secs : secs;
document.getElementById("timerDisplay").innerText = formattedMins + ":" + formattedSecs;
}
function proceedUpdate() {
try {
var fso = new ActiveXObject("Scripting.FileSystemObject");
@@ -180,7 +180,7 @@ try {
</script>
</head>
<body onload="initWindow()">
<div class="header">JCT600 - IT SUPPORT</div>
<div class="header">JCT600 IT SUPPORT</div>
<div class="message">
An automatic update for 8x8 Work has been scheduled.<br>
Please save active work or click <b>Update Now</b> to begin.
@@ -196,7 +196,7 @@ try {
# --------------------------------------------------------------------------
# Step 3: Launch Unclosable Dialog in Active User Session
# --------------------------------------------------------------------------
Write-Host "[3/4] Launching prompt on logged-in user desktop..." -ForegroundColor Cyan
Write-Host "[3/4] Launching sleep-safe prompt on logged-in user desktop..." -ForegroundColor Cyan
$loggedUser = (Get-CimInstance Win32_ComputerSystem).UserName
@@ -205,11 +205,11 @@ try {
} else {
$taskName = "JCT600_8x8_UpdatePrompt"
# mshta.exe runs the HTML Application natively inside the user's interactive desktop
# Create scheduled task configured to wake/stay active during user session
schtasks.exe /Create /TN $taskName /TR "mshta.exe `"$htaPromptPath`"" /SC ONCE /ST 00:00 /IT /RU "$loggedUser" /F | Out-Null
schtasks.exe /Run /TN $taskName | Out-Null
Write-Host "Prompt active for $loggedUser. Waiting for user action or timer expiration..." -ForegroundColor Yellow
Write-Host "Prompt active for $loggedUser. Waiting for user action or wall-clock expiration..." -ForegroundColor Yellow
while (-not (Test-Path $flagFile)) {
Start-Sleep -Seconds 2
}