Update 8x8_Work_Updater.ps1
This commit is contained in:
+21
-20
@@ -1,8 +1,8 @@
|
||||
# ==============================================================================
|
||||
# Script Name: 8x8_Work_Updater.ps1
|
||||
# Description: Downloads 8x8, launches an interactive JCT600 GUI inside the
|
||||
# active user's desktop session using Explorer process injection,
|
||||
# waits for response/timer, silently installs, and relaunches 8x8.
|
||||
# Description: Downloads 8x8 with a progress bar, injects a user-session GUI
|
||||
# countdown dialog via HKU RunOnce, waits for user response/timer,
|
||||
# silently installs, and relaunches 8x8.
|
||||
# ==============================================================================
|
||||
|
||||
# Ensure script is running elevated
|
||||
@@ -21,7 +21,7 @@ if (-not (Test-Path $workDir)) {
|
||||
New-Item -Path $workDir -ItemType Directory -Force | Out-Null
|
||||
}
|
||||
|
||||
# Ensure standard users have full read/execute permissions to the folder
|
||||
# Ensure standard users have full read/execute permissions to the working folder
|
||||
$acl = Get-Acl $workDir
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Users", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
|
||||
$acl.AddAccessRule($rule)
|
||||
@@ -60,7 +60,7 @@ try {
|
||||
$totalMB = [math]::Round($totalBytes / 1MB, 2)
|
||||
$barLength = 30
|
||||
$filledLength = [math]::Round(($percent / 100) * $barLength)
|
||||
$bar = ("█" * $filledLength) + ("░" * ($barLength - $filledLength))
|
||||
$bar = ("#" * $filledLength) + ("-" * ($barLength - $filledLength))
|
||||
|
||||
Write-Host "`rDownloading: [$bar] $percent% ($downloadedMB MB / $totalMB MB)" -NoNewline -ForegroundColor Yellow
|
||||
}
|
||||
@@ -181,34 +181,35 @@ $form.Dispose()
|
||||
[System.IO.File]::WriteAllText($guiScript, $guiContent, $utf8NoBom)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Step 3: Trigger Interactive GUI in Active Desktop Session
|
||||
# Step 3: Trigger Interactive GUI via Active Desktop Process Execution
|
||||
# --------------------------------------------------------------------------
|
||||
Write-Host "[3/5] Launching interactive dialog on user desktop..." -ForegroundColor Cyan
|
||||
Write-Host "[3/5] Launching interactive dialog on active user desktop..." -ForegroundColor Cyan
|
||||
|
||||
$explorerProc = Get-Process -Name explorer -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
|
||||
if (-not $explorerProc) {
|
||||
Write-Warning "No active desktop session detected. Proceeding directly to update."
|
||||
} else {
|
||||
# Inject GUI execution trigger into the active user's explorer shell context
|
||||
$taskName = "JCT600_8x8_GUI_Task"
|
||||
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -WindowStyle Hidden -File `"$guiScript`""
|
||||
# Query active user SID from Explorer process
|
||||
$userSid = (Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $($explorerProc.Id)" | Invoke-CimMethod -MethodName GetOwnerSid).Sid
|
||||
|
||||
# Using Interactive logon trigger bypasses Session 0 isolation
|
||||
$trigger = New-ScheduledTaskTrigger -At (Get-Date).AddSeconds(1) -Once
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -Priority 0
|
||||
|
||||
# Register task under INTERACTIVE user token
|
||||
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||
Register-ScheduledTask -TaskName $taskName -InputObject $task -User "INTERACTIVE" -Force | Out-Null
|
||||
Start-ScheduledTask -TaskName $taskName | Out-Null
|
||||
if ($userSid) {
|
||||
# Inject RunOnce command directly into active user registry hive
|
||||
$regPath = "Registry::HKEY_USERS\$userSid\Software\Microsoft\Windows\CurrentVersion\RunOnce"
|
||||
$cmdToRun = "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$guiScript`""
|
||||
|
||||
if (Test-Path $regPath) {
|
||||
Set-ItemProperty -Path $regPath -Name "JCT600_8x8_UpdateGUI" -Value $cmdToRun -Force
|
||||
|
||||
# Signal Explorer shell to execute RunOnce entries for active session
|
||||
Start-Process "explorer.exe" -ArgumentList "shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}" -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Waiting for user dialog response or timer expiration (1 hour max)..." -ForegroundColor Yellow
|
||||
while (-not (Test-Path $flagFile)) {
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
||||
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user