1

I have a very simple program that copies file from one location to another, and I have scheduled it run everyday using the windows scheduler.

  1. But when the scheduler launches it, it fails and logs System.UnauthorizedAccessException: Access to the path '' is denied.
  2. If I just launch the program by double clicking it, it fails with the same error as above.
  3. But when I run the program manually by doing a Run as and use the same credential that I used in the windows scheduler it runs successfully.

The credential used in all the three cases is the one that I use to login to the system.

Can anybody please help me in understanding why this is happening?

Thank you

Update

No reason could be found for this behaviour, so implemented the following workaround -

  1. Wrote a program to copy the file.
  2. Wrote a launcher program. This program launched the file copy program by impersonating the user.
  3. Scheduled the launcher program in windows scheduler.

Used info at http://www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx to impersonate.

unlimit
  • 3,672
  • 2
  • 26
  • 34
  • What version of Windows are you running (Windows7, W2K8 Server, etc)? Do you have the scheduled task set to "Run whether user is logged in or not"? Have you specified the proper path to start the application in? – rsbarro Mar 26 '11 at 02:07
  • Answers to the questions Windows 2003, Yes, Yes – unlimit Mar 27 '11 at 00:27

0 Answers0