sync: auto-sync from HOWARD-HOME at 2026-07-07 13:55:03
Author: Howard Enos Machine: HOWARD-HOME Timestamp: 2026-07-07 13:55:03
This commit is contained in:
@@ -47,14 +47,26 @@ if (-not (Test-Path $Script)) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Resolve the py launcher's full path (the action's Execute wants an absolute
|
||||
# path; "py" alone usually resolves but we pin it for reliability under the
|
||||
# Task Scheduler's environment).
|
||||
$PyCmd = Get-Command py -ErrorAction SilentlyContinue
|
||||
# Resolve pythonW.exe (the GUI-subsystem Python host) so the detector runs with NO
|
||||
# console window flashing on the desktop at logon / every 4h. Using py.exe or
|
||||
# python.exe (console subsystem) draws a visible window each run. Prefer pythonw next
|
||||
# to the active interpreter; fall back to a PATH lookup, then py.exe as a last resort.
|
||||
$PyPath = $null
|
||||
$PyCmd = Get-Command py -ErrorAction SilentlyContinue
|
||||
if ($null -ne $PyCmd) {
|
||||
$PyPath = $PyCmd.Source
|
||||
} else {
|
||||
$PyPath = "py" # fall back to PATH resolution at run time
|
||||
try {
|
||||
$exe = (& py -c "import sys;print(sys.executable)").Trim()
|
||||
$wexe = Join-Path (Split-Path $exe) "pythonw.exe"
|
||||
if (Test-Path $wexe) { $PyPath = $wexe }
|
||||
} catch { }
|
||||
}
|
||||
if ($null -eq $PyPath) {
|
||||
$PwCmd = Get-Command pythonw -ErrorAction SilentlyContinue
|
||||
if ($null -ne $PwCmd) { $PyPath = $PwCmd.Source }
|
||||
}
|
||||
if ($null -eq $PyPath) {
|
||||
if ($null -ne $PyCmd) { $PyPath = $PyCmd.Source } else { $PyPath = "py" }
|
||||
Write-Host "[WARNING] pythonw.exe not found; task may flash a console window." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
$Action = New-ScheduledTaskAction `
|
||||
@@ -76,7 +88,8 @@ $Settings = New-ScheduledTaskSettingsSet `
|
||||
-ExecutionTimeLimit (New-TimeSpan -Minutes 30) `
|
||||
-MultipleInstances IgnoreNew `
|
||||
-StartWhenAvailable `
|
||||
-DontStopOnIdleEnd
|
||||
-DontStopOnIdleEnd `
|
||||
-Hidden
|
||||
|
||||
Register-ScheduledTask `
|
||||
-TaskName $TaskName `
|
||||
|
||||
Reference in New Issue
Block a user