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