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.
- But when the scheduler launches it, it fails and logs System.UnauthorizedAccessException: Access to the path '' is denied.
- If I just launch the program by double clicking it, it fails with the same error as above.
- 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 -
- Wrote a program to copy the file.
- Wrote a launcher program. This program launched the file copy program by imperson开发者_开发百科ating the user.
- Scheduled the launcher program in windows scheduler.
Used info at http://www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx to impersonate.
精彩评论