VB6 app not executing as scheduled task unless user is logged on

Posted by Tedd Hansen on Stack Overflow See other posts from Stack Overflow or by Tedd Hansen
Published on 2010-04-09T18:59:23Z Indexed on 2010/04/09 19:03 UTC
Read the original article Hit count: 410

Filed under:
|

Hi

Would greatly apprechiate some help on this one! It may be a tricky one. :)

Problem

  • I have an VB6 application which is set up as scheduled task. It starts every time, but when executing CreateObject it fails if user is not logged on to computer.
  • I am looking for information on what could cause this. Primary suspicion is that some Windows API fails.

Key points

  • Behaviour confirmed on Windows 2000, 2003, 2008 and Vista.
  • The application executes as user X at scheduled time, executed by Windows Task Scheduler.
  • It executes every time. Application does start! -- If user X is logged on via RDP it runs perfectly. (Note that user doesn't need to be connected, only logged on) -- If user X is not logged on to computer the application fails.

Failure point

  • Application fails when using CreateObject() to instansiate a DCOM object which is also part of the application.
  • The DCOM objects declare .dll-references at startup (globally/on top of .bas-file) and run a small startup function. Failure must be during startup, possibly in one of the .dll-declarations.

Thoughts

After some Googling my initial suspicion was directed at MAPI. From what I could see MAPI required user to be logged on. The application has MAPI references. But even with all MAPI references removed it still does not work.

What is the difference if an user is logged on? Registry mapping? Environment? explorer.exe is running. Isn't the user logged on when application executes as the user?

What info would help?

  • A definitive answer would be truly great.
  • Any information regarding any VB6 feature/Windows API that could act differently depending on wether user is logged on or not would definitively help.
  • Similar experiences may lead me in the right direction.
  • Tips on debuggin this.

Thanks! :)

© Stack Overflow or respective owner

Related posts about vb6

Related posts about dcom