5

I have a simple vb.net application. When I go to bin\debug\program.exe and double click the program runs perfect. The same program will not execute using task scheduler. When I create a scheduled task and click 'run' it just pops up a console window for a second, closes. Additionally, this same program used to run with task scheduler. One day, it just stopped working.

ps:
I have this program code managed in svn so I can safely say that the code has not changed.

Doug Chamberlain
  • 11,192
  • 9
  • 51
  • 91
  • If possible have you tried running the same application on a different machine? Does your program needs admin rights? What does the program do? What is your OS (Vista, Win 7) ? Can you provide us with more details. – Searock Jan 10 '11 at 15:46
  • repasting the location into the run textbox fixed the issue. I tested this and if you create a task that points to a file exe that does not exist you get a 'could not start message'. So I don't know how I was getting the error code I was getting. – Doug Chamberlain Jan 10 '11 at 19:33

5 Answers5

17

The 0xe0434f4d exit code is quite meaningful. That's the native exception code for a managed exception. In other words, your app is crashing with an unhandled exception when it is run by task manager. I could guess at reasons why, but it is fairly pointless. Find out yourself, write an event handler for AppDomain.CurrentDomain.UnhandledException and log the value of e.ExceptionObject.ToString(). That gives you the exception message and the stack trace, almost always good enough to find out why it is bombing.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
3

Personally I don't believe in magic :-)

  1. Double-check that the source code is not modified comparing to the working version.
  2. Are you sure that the program is executed at all? Might be some permissions-related issues (from which user does the program execute and so on).
  3. (if #2 passes) Try debugging it to see what causes the problem.
volpav
  • 5,090
  • 19
  • 27
  • 1. I did double check. Always a good idea.
    2. Ran the program using f5 debug, ran fine
    3. Ran the version from the bin\debug folder that ran fine.
    4. re-re-re copied and pasted the run command from windows explorer into the task run properties....fixed.
    – Doug Chamberlain Jan 10 '11 at 19:21
  • 1
    .. and this is why you (meaning me) should always check everything (even the obvious stuff). – Doug Chamberlain Jan 10 '11 at 19:22
2

Actually, this problem was caused by permissions. As a scheduled task the job did not have permissions to certain folders and files.

Doug Chamberlain
  • 11,192
  • 9
  • 51
  • 91
0

One thing I have noticed with certain scheduled tasks on Windows 2000 and Windows XP is that every time the machine is rebooted, we have to re-enter the password on some of the tasks. Others continue to work without it, and I never identified the difference.

WGroleau
  • 448
  • 1
  • 9
  • 26
0

I would check to see what user the scheduled task is running under. It maybe that is running with an account whose password has expired (as you said it has been running previously) and requires this to be changed.

Dean
  • 5,896
  • 12
  • 58
  • 95