Search code examples
vb6

No printers showing when component service tries to print


I have this old component service (COM+ Application) that gets called and tries to print a document. It runs as a specific user that acts as a service account that is never actually logged on to. For some reason my debug output is showing 0 printers listed when I make the call to the COM+ App. However, if I open a command prompt as that user I can make the same call and see all the printers.

It's like it's requiring the profile to be loaded before printers are shown. Is there a way around this? Currently my only work around is to do something really crazy like schedule a task to run each day for 1 day that just runs cmd.exe /c "pause". I didn't have to do this in the past (this has been used for many years). I remember something about not unloading registry profiles that might have helped me. Is there anything that I can add to my application (com+ app) that could load the printers and make them available for me?


Solution

  • It looks like I was on the right track just needed to know exactly what to search for. It seems Do not forcefully unload the user registry at user logoff was what I was after.

    Ref: https://learn.microsoft.com/en-us/troubleshoot/windows-server/application-management/complus-server-application-not-work

    Adding this to your registry will stop the profiles from getting logged off after they have logged on once.

    Save a file with the contents below and name it something like Disable Profile Logoff.reg then double click it to add it to your registry.

    REGEDIT4
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
    "DisableForceUnload"=dword:00000001