From 72523d178579b26081376c1a4a8994c35e5003eb Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Thu, 19 Jun 2025 01:18:48 -0600 Subject: [PATCH] foam_sync.ps1 (LIFEBALANCE) 2025-06-19T01:18:48Z --- foam_sync.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/foam_sync.ps1 b/foam_sync.ps1 index 56aa040..78ee4ad 100644 --- a/foam_sync.ps1 +++ b/foam_sync.ps1 @@ -97,14 +97,15 @@ try { # 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\`"" - # 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'\`"" + # TEMPORARY: For troubleshooting the flashing window. + # We simplify the command to see if the intermediate PowerShell itself has an issue parsing/executing Start-Process. + # Errors from this *intermediate* powershell should appear in the Task Scheduler history. + $actionArgumentForRegistration = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command \`"$commandToRunViaStartProcess\`"" # Reverted to original, but without explicit redirection for now. # 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 2> '$intermediateErrorLog'" # Match the temporary change + $expectedRetrievedActionArgument = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $commandToRunViaStartProcess" # Reverted to match the above $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration