Question

I would greatly appreciate 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 a user is not logged on to computer.
  • I am looking for information on what could cause this. My 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 instantiate 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 whether user is logged on or not would definitively help.
  • Similar experiences may lead me in the right direction.
  • Tips on debugging this.
Was it helpful?

Solution 3

We never found out what caused this.

Instead I made a RDP client which I put in Scheduled Tasks. It logged on a user which had the required app in startup. After some time the RDP client forcefully logged out the user (to prevent runaway apps hanging the system).

Not the perfect solution, but a solution nevertheless.

OTHER TIPS

The VB application possibly needs to get hold on to running services that are only running when a user is logged on.

What is the "Identity" setting of the DCOM component.

C:\WINDOWS\system32\Com\comexp.msc

  1. C:\WINDOWS\system32\Com\comexp.msc
  2. Component Services
  3. My Computer
  4. DCOM Config
  5. The DCOM Object, right click properties
  6. Identity tab

Set it to "This User" and set a user with the required permissions, and then run the app as your self to see if the DCOM component can still work, then try again from the scheduler.

has your VB6 forms?
because when you run scheduled, it run "as a service", so it can't have forms, or if it have forms an enviroment where to show them.

I don't remember what I have used, but exists generic "run as a service" converter exe to run windowed VB6 projects.

Also perhaps you can easy convert your code to run as a VBScript, and schedule it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top