Update 8x8_Work_Updater.ps1
This commit is contained in:
+19
-19
@@ -1,8 +1,8 @@
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Script Name: 8x8_Work_Updater.ps1
|
# Script Name: 8x8_Work_Updater.ps1
|
||||||
# Description: Downloads 8x8 with a progress bar, launches an unclosable HTA
|
# Description: Downloads 8x8 with a progress bar, launches an unclosable HTA
|
||||||
# countdown prompt in the user's session (no X button), waits for
|
# countdown prompt with real-clock wall-time tracking (sleep-safe),
|
||||||
# user action or 1-hour timeout, installs silently, and relaunches 8x8.
|
# silently installs, and relaunches 8x8 Work.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# Ensure script is running elevated
|
# 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 = @"
|
$htaContent = @"
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>JCT600 IT Support - 8x8 Work Update</title>
|
<title>JCT600 IT Support — 8x8 Work Update</title>
|
||||||
<HTA:APPLICATION
|
<HTA:APPLICATION
|
||||||
ID="o8x8Update"
|
ID="o8x8Update"
|
||||||
APPLICATIONNAME="JCT600 8x8 Work Update"
|
APPLICATIONNAME="JCT600 8x8 Work Update"
|
||||||
@@ -142,30 +142,30 @@ try {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script language="javascript">
|
<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() {
|
function initWindow() {
|
||||||
window.resizeTo(480, 270);
|
window.resizeTo(480, 270);
|
||||||
window.moveTo((screen.width - 480) / 2, (screen.height - 270) / 2);
|
window.moveTo((screen.width - 480) / 2, (screen.height - 270) / 2);
|
||||||
updateDisplay();
|
tick();
|
||||||
setInterval(tick, 1000);
|
setInterval(tick, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
if (totalSeconds > 0) {
|
var now = new Date().getTime();
|
||||||
totalSeconds--;
|
var remainingMilliseconds = targetTime - now;
|
||||||
updateDisplay();
|
var totalSeconds = Math.floor(remainingMilliseconds / 1000);
|
||||||
} else {
|
|
||||||
proceedUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateDisplay() {
|
if (totalSeconds > 0) {
|
||||||
var mins = Math.floor(totalSeconds / 60);
|
var mins = Math.floor(totalSeconds / 60);
|
||||||
var secs = totalSeconds % 60;
|
var secs = totalSeconds % 60;
|
||||||
var formattedMins = mins < 10 ? "0" + mins : mins;
|
var formattedMins = mins < 10 ? "0" + mins : mins;
|
||||||
var formattedSecs = secs < 10 ? "0" + secs : secs;
|
var formattedSecs = secs < 10 ? "0" + secs : secs;
|
||||||
document.getElementById("timerDisplay").innerText = formattedMins + ":" + formattedSecs;
|
document.getElementById("timerDisplay").innerText = formattedMins + ":" + formattedSecs;
|
||||||
|
} else {
|
||||||
|
proceedUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function proceedUpdate() {
|
function proceedUpdate() {
|
||||||
@@ -180,7 +180,7 @@ try {
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="initWindow()">
|
<body onload="initWindow()">
|
||||||
<div class="header">JCT600 - IT SUPPORT</div>
|
<div class="header">JCT600 — IT SUPPORT</div>
|
||||||
<div class="message">
|
<div class="message">
|
||||||
An automatic update for 8x8 Work has been scheduled.<br>
|
An automatic update for 8x8 Work has been scheduled.<br>
|
||||||
Please save active work or click <b>Update Now</b> to begin.
|
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
|
# 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
|
$loggedUser = (Get-CimInstance Win32_ComputerSystem).UserName
|
||||||
|
|
||||||
@@ -205,11 +205,11 @@ try {
|
|||||||
} else {
|
} else {
|
||||||
$taskName = "JCT600_8x8_UpdatePrompt"
|
$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 /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
|
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)) {
|
while (-not (Test-Path $flagFile)) {
|
||||||
Start-Sleep -Seconds 2
|
Start-Sleep -Seconds 2
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user