Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File not found using Task Scheduler

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.

like image 285
rdem Avatar asked Jan 31 '14 09:01

rdem


People also ask

Why is Task Scheduler not running my task?

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.

How do I run a file in Task Scheduler?

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.

What is C :\ Windows System32 tasks?

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 .


1 Answers

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)

like image 148
Kaspars Ozols Avatar answered Oct 05 '22 23:10

Kaspars Ozols