2

I have an exe that developed on visual studio.
When we run it on the server, it will execute with out any issues.
But when I tried to execute it through Task scheduler, it is not running.
Please find the below error message from event viewer.
Please help me to resolve the issue

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.DirectoryNotFoundException
Stack:
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.IO.Directory.InternalCreateDirectory(System.String, System.String, System.Object, Boolean)
   at System.IO.DirectoryInfo.Create()
   at CentralMarketTransfer.HEB.CentralMarketTransfer.util.SimpleLogging.LogMessageToFile(System.String)
   at CentralMarketTransfer.HEB.CenteralMarketTransfer.main.ProjectMain.Main(System.String[])
GSerg
  • 71,102
  • 17
  • 141
  • 299

2 Answers2

1

Try to explicitly set the start directory for the task. You can set in Task Scheduler.

Select Task -> Right Click -> Properties -> Actions Tab -> Select Action -> Edit -> Start in (optional)
Pradeep Vairamani
  • 3,299
  • 2
  • 30
  • 52
0

To me it seems that the current running directory is different when the exe is executed directly and when running through the task scheduler.

For reference:

What is the default working directory for a scheduled task in Windows 2008 R2?

Specifying the running directory for Scheduled Tasks using schtasks.exe

Community
  • 1
  • 1
Manish Dalal
  • 1,648
  • 1
  • 8
  • 12