In my C# code, I reference to an XML file "file.xml", which is in the same directory as the executable itself, using XmlDocument.
The application runs perfectly well in VS, but when I try to run the application using Task Scheduler, I get a System.IO.FileNotFoundException
, even though everything's the same.
I reference to the file using @".\file.xml"
. Is this some weird stuff specific to Task Scheduler? Appropriate permissions are used.
Open Task Scheduler. Double-click the task that won't run. Go to the General tab. At the bottom, enable the 'Run with highest privileges' option and grant it admin access.
Expand the Task Scheduler Library branch. Select the folder with your tasks. To run a task on demand, right-click it and select the Run option. To edit a task, right-click it and select the Properties options.
C:\Windows\System32\Tasks contains XML files that contain the definitions of scheduled tasks. The directory structure under %SYSTEMROOT%\System32\Tasks seems to correspond to the registry key structure under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree .
Try to set startup directory for the task. You can set in Task Scheduler.
Select Task -> Right Click -> Properties -> Actions Tab -> Select Action -> Edit -> Start in (optional)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With