VB6 app does not run as scheduled task if user is not logged in
I really appreciate your help with this! It can be tricky. :)
Problem
- I have a VB6 application that is configured as a scheduled job. It runs every time, but on execution
CreateObject()
it fails if the user is not logged into the computer. - I am looking for information on what might be causing this. My primary suspicion is that some Windows APIs are failing.
Key points
- Behavior confirmed on Windows 2000, 2003, 2008, and Vista.
- The application runs as user X on a schedule, executed by the Windows Task Scheduler.
- Is performed every time. The application is starting!
- If user X logs in via RDP, it works fine. (Note that the user does not need to connect, only login)
- If user X is not logged into the computer, the application will not work.
Point of failure
- The application does not work when used
CreateObject()
to create a DCOM object that is also part of the application. - DCOM objects declare DLL references on startup (globally / on top of the .bas file) and run a small startup function. The malfunction should be during startup, perhaps in one of the DLL declarations.
Thoughts
After some Googling, my initial suspicion was directed towards MAPI. From what I could see, MAPI obliged the user to login. The app has MAPI links. But even with all MAPI links removed, it still doesn't work.
What's the difference if the user is logged in? Displaying the registry? Environment? Explorer.exe is running.
Not a user logged in when the application is running as a user?
What information will help?
- The final answer would be really great.
- Any information about any VB6 / Windows API function that can act differently depending on whether the user is logged in or not will be definitively helpful.
- An experience like this might lead me in the right direction.
- Debugging tips.
source to share
We didn't know what caused this.
Instead, I made an RDP client that I placed in scheduled jobs. He logged in to the user who had the required application on startup. After some time, the RDP client forcibly disabled the user (to prevent system-dependent applications from running).
Not a perfect solution, but a solution nonetheless.
source to share
What is the DCOM Component Identity parameter.
C: \ WINDOWS \ system32 \ Com \ comexp.msc
- C: \ WINDOWS \ system32 \ Com \ comexp.msc
- Component Services
- My computer
- DCOM configuration
- DCOM Object Right Click Properties
- Identification tab
Set it to This User and set a user with the required permissions, then run the application as your self to see if the DCOM component can work, then try again from the scheduler.
source to share
have your VB6 forms?
because when you run scheduled, it runs "as a service", so it cannot have forms or if it has an environment in which to show them.
I don't remember what I used, but there is a generic "run as a service" converter exe to run VB6 windowed projects.
Plus, you can easily convert your code as VBScript and schedule it.
source to share