Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server 2008 Task Scheduler Mapped Drive Access C#

I'm trying do get Server 2008's Task Scheduler to run a C# console app which backs up data to a mapped backup drive somewhere on FastHosts network.

I've written a test app which simply does this

Directory.CreateDirectory("Z:\" + DateTime.Now.Ticks.ToString());

i.e. just creates a directory on the root of this Z drive.

This works fine when I just run the .exe but when I schedule it in Task Scheduler it doesn't create the directory but says the task has completed with return code 3762507597 - I can't find any info on what this means.

I'm running the task with the highest Admin privelages as far as I can see.

like image 852
user219313 Avatar asked Jan 23 '23 06:01

user219313


2 Answers

If this ever helps someone else, the issue I had was due to the 'action' needing to have the 'Start in' path set to the same path as the application itself. Otherwise I'm guessing it's trying to write to the system root.

A bit cryptic!

like image 89
Chris Godfrey Avatar answered Feb 01 '23 21:02

Chris Godfrey


Not sure why is now works but I replaced the mapped drive letter i.e. 'Z' with the full name i.e. \[IP address]]\C$ and it now works.

Some weird permissions thing no doubt.

like image 36
user219313 Avatar answered Feb 01 '23 21:02

user219313