I have a console application,whose target version is .Net Framework 3.5. When I try to trigger the complied exe manually, the program executes and does its job perfectly. But the exe is not at all getting triggered when using a Task Scheduler.
The error details in Task Sceduler is as follows:
last run result 0xE0434F4D
Edits:
The event log is as follows,
Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0
Problem signature:
P1: flvtomp4converter.exe
P2: 1.0.0.0
P3: 4ffa8abc
P4: mscorlib
P5: 2.0.0.0
P6: 4e1539fa
P7: 349e
P8: 119
P9: System.IO.DirectoryNotFound
P10:
What is happening here?
Welcome to wonderful world of Windows 2008 family. This is about under what user your application scheduled to run in Task Scheduler and what permission that specific user have to all(!!!) folders involved in processing by your application. Also you must make sure that this user authorized to run batch processes in security settings. Just been member of administrators group no longer is enough!
In my case, it's because my console app trying to create an log.txt
file inside C:\Windows\System32
and the task scheduler has no permission to create a new file inside that folder.
This is happen because i don't specify an absolute filename where to put the log file.
Let me explain this with an example of my code :
I have a program inside this directory D:\somefolder\
and the .exe
directory is D:\somefolder\program.exe
This is a snapshot of my code (visual basic)
Wrong :
Dim logFileName As String = "log.txt"
/*
Create file based on logFileName directory
*/
.exe
via windows explorer -> it'll create a log file with directory D:\somefolder\log.txt
(no problem).exe
via task scheduler -> it'll create a log file with directory C:\Windows\System32\log.txt
(This will leave last run result 0xE0434F4D)Correct :
Dim logFileName As String = AppDomain.CurrentDomain.BaseDirectory + "/log.txt"
/*
Create file based on logFileName directory
*/
If I execute .exe
via windows explorer -> it'll create a log file with directory D:\somefolder\log.txt
(no problem)
If I execute .exe
via task scheduler -> it'll create a log file with directory D:\somefolder\log.txt
(no problem)
So you need to specify an absolute filename where to put the log file. In my example I use AppDomain.CurrentDomain.BaseDirectory
User contributions licensed under CC BY-SA 3.0