v1.6.0: Switch to user-logon task, migrate API to tsgwp00525 FQDN

- Install-ScheduledTask.ps1: run at user logon with visible UI (was startup
  with no UI), hardcode install path to C:\eDNC-Fix
- Migrate ShopDB API URL from http://geitshopdb/api.asp to
  https://tsgwp00525.rd.ds.ge.com/shopdb/api.asp in code and docs
- eDNC-SpecialCharFix.ps1: ~250 line rework (see diff)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-04-17 12:03:50 -04:00
parent 28641c47c5
commit 2748bfa037
4 changed files with 302 additions and 175 deletions

View File

@@ -1,13 +1,13 @@
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Installs eDNC Special Character Fix as a scheduled task that runs at startup with admin rights.
Installs eDNC Special Character Fix as a scheduled task that runs at user logon with visible UI.
.DESCRIPTION
Creates a Windows scheduled task that:
- Runs at system startup
- Runs at user logon (visible window for debugging)
- Runs with highest privileges (Administrator)
- Runs whether user is logged on or not
- Shows the monitoring UI to the logged-in user
- Automatically restarts if it stops
Monitors: C:\Dnc_Files\Q for *.pun files
@@ -29,7 +29,10 @@ param(
)
$TaskName = "eDNC Special Character Fix"
$ScriptPath = Join-Path $PSScriptRoot "eDNC-SpecialCharFix.ps1"
# IMPORTANT: Always use the local installation path, NOT $PSScriptRoot
# This ensures the task runs from C:\eDNC-Fix even if installed from S:\ share
$LocalInstallPath = "C:\eDNC-Fix"
$ScriptPath = Join-Path $LocalInstallPath "eDNC-SpecialCharFix.ps1"
if ($Uninstall) {
Write-Host "Removing scheduled task '$TaskName'..." -ForegroundColor Yellow
@@ -38,9 +41,18 @@ if ($Uninstall) {
exit 0
}
# Verify script exists
# Verify local installation exists
if (-not (Test-Path $LocalInstallPath)) {
Write-Host "[ERROR] Local installation folder not found: $LocalInstallPath" -ForegroundColor Red
Write-Host ""
Write-Host "Please run Deploy.bat first to copy files to $LocalInstallPath" -ForegroundColor Yellow
exit 1
}
if (-not (Test-Path $ScriptPath)) {
Write-Host "[ERROR] Script not found: $ScriptPath" -ForegroundColor Red
Write-Host ""
Write-Host "Please run Deploy.bat first to copy files to $LocalInstallPath" -ForegroundColor Yellow
exit 1
}
@@ -61,14 +73,14 @@ if ($existingTask) {
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
}
# Build the PowerShell command
$Arguments = "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$ScriptPath`""
# Build the PowerShell command (visible window for debugging)
$Arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$ScriptPath`""
# Create the scheduled task
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $Arguments -WorkingDirectory $PSScriptRoot
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $Arguments -WorkingDirectory $LocalInstallPath
# Trigger: At startup
$Trigger = New-ScheduledTaskTrigger -AtStartup
# Trigger: At user logon (shows UI to logged-in user)
$Trigger = New-ScheduledTaskTrigger -AtLogOn
# Settings
$Settings = New-ScheduledTaskSettingsSet `
@@ -79,8 +91,8 @@ $Settings = New-ScheduledTaskSettingsSet `
-RestartCount 3 `
-ExecutionTimeLimit (New-TimeSpan -Days 9999)
# Principal: Run as SYSTEM with highest privileges
$Principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
# Principal: Run as the logged-in user with highest privileges (for visible UI)
$Principal = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Users" -RunLevel Highest
# Register the task
$Task = New-ScheduledTask -Action $Action -Trigger $Trigger -Settings $Settings -Principal $Principal -Description "Monitors DNC folder and removes invalid special characters (0xFF) from program files."
@@ -89,7 +101,8 @@ Register-ScheduledTask -TaskName $TaskName -InputObject $Task | Out-Null
Write-Host "Scheduled task created successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "The task will start automatically at system boot." -ForegroundColor White
Write-Host "The task will start automatically when any user logs in." -ForegroundColor White
Write-Host "A visible PowerShell window will show the monitoring UI." -ForegroundColor White
Write-Host ""
Write-Host "To start it now, run:" -ForegroundColor Yellow
Write-Host " Start-ScheduledTask -TaskName '$TaskName'"