foam_sync.ps1 (LIFEBALANCE) 2025-06-19T01:14:24Z
This commit is contained in:
@ -95,11 +95,16 @@ try {
|
||||
# 5. Argument string FOR THE TASK SCHEDULER to pass to the first powershell.exe.
|
||||
# The $commandToRunViaStartProcess is the value for -Command, and needs to be quoted for registration.
|
||||
# e.g., -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Start-Process -FilePath powershell.exe -ArgumentList '-NoProfile -NonInteractive -ExecutionPolicy Bypass -File \"C:\path\to your script.ps1\"' -WindowStyle Hidden"
|
||||
$actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess\`""
|
||||
# $actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess\`""
|
||||
|
||||
# TEMPORARY: For troubleshooting the flashing window. This will create an error log for the intermediate powershell.
|
||||
$intermediateErrorLog = Join-Path -Path $logDir -ChildPath "intermediate_error.log"
|
||||
$actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess 2> '$intermediateErrorLog'\`""
|
||||
|
||||
|
||||
# 6. Expected argument string WHEN RETRIEVED by Get-ScheduledTask.
|
||||
# Task Scheduler/PowerShell often strips the outermost quotes from the -Command value when retrieved.
|
||||
$expectedRetrievedActionArgument = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $commandToRunViaStartProcess"
|
||||
$expectedRetrievedActionArgument = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $commandToRunViaStartProcess 2> '$intermediateErrorLog'" # Match the temporary change
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user