This has worked well for months, but several days ago the FileBot call, which is initiated via Process.Start(), has been failing with an exception.
Here's the information that seems relevant:
- This is a standard C#/.NET Console app.
- Handbrake and FileBot is being invoked via System.Diagnostics.Process class.
- The command line for FileBot is: filebot.exe -rename "{TargetPath}" --format "{n} - {s00e00.lower()} - {t}" --lang en -non-strict
- The exception is triggered upon call to Process.Start()
- The call to Handbrake CLI is continuing to succeed.
- If I launch the program exe manually (either from CMD or by simply double-clicking it, it works OK). It only fails when started by Task Scheduler.
- Task Scheduler is set to trigger every 3 hours, to run whether user is logged in or not, and to run with highest privileges. It runs under my own login, which is a local administrator of the machine. Generally the machine in question wakes up to run the task, then goes back to sleep.
- Exception: System.ComponentModel.Win32Exception (0x80004005): A specified logon session does not exist. It may already have been terminated
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
... - I've tried turning on UseShellExecute (even though this means I cannot collect the standard output and standard error from the FileBot processing run)...with no change in behavior
- I've tried supplying user credentials to the Process.ProcessStartInfo (including loading user profile), even though Task Scheduler is already starting the exe under my user context...with no change in behavior.
- I've tried instead starting cmd.exe with "/C" parameter, with the rest of the command line passed to it, and that caused cmd.exe to simply print a message that it could not start the program. This works in a console window, but not with the scheduled task.
- Finally, I tried launching one of the two "real" filebot.exe's from inside AppData, even though I know this is not the correct way to launch vs. the execution alias (just "filebot.exe")...with no change in behavior.