Microsoft KB Archive/184291

From BetaArchive Wiki
Knowledge Base


Article ID: 184291

Article Last Modified on 7/10/2006



APPLIES TO

  • Microsoft Active Server Pages 4.0
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0



This article was previously published under Q184291

SYMPTOMS

A COM object that sends output to a printer fails when called from Active Server Pages (ASP) but functions correctly when called from an interactive application. This COM object could be either a commercial product such as a Microsoft Office application, or a custom third-party object. A common error message is "ClassName error '800a01e2' Printer error."

CAUSE

The standard APIs that most objects use to print depend on registry entries located in HKEY_CURRENT_USER. This registry hive is dynamic. Depending on which user context the process is running under, different information will be loaded into this hive. ASP pages run under IIS, which is running as the SYSTEM account. When you create an instance of a COM object in your ASP code, by default, it will also run as the SYSTEM account. By default, the SYSTEM account does not have any printers set up in the registry.

RESOLUTION

You can set up printers for the SYSTEM account to resolve this problem. To set up printers for the SYSTEM account, perform the following:

This method requires you to modify the registry using the Registry Editor.

WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows to correct them. Microsoft cannot guarantee that any problems resulting from the use of Registry Editor can be solved. Use this tool at your own risk.

  1. Ensure that the user you are currently logged into on the server has the desired printers installed.
  2. Launch the Registry Editor (Regedit.exe).
  3. Select the following key:

          HKEY_CURRENT_USER
             \Software\Microsoft\Windows NT\Current Version\Devices
    
                        
  4. From the Registry menu, click Export Registry File.
  5. In the File Name text box, type c:\Devices.reg.
  6. Select the following key:

          HKEY_CURRENT_USER
             \Software\Microsoft\Windows NT\Current Version\PrinterPorts
    
                        
  7. From the Registry menu, click Export Registry File.
  8. In the File Name text box, type c:\PrinterPorts.reg.
  9. Select the following key:

          HKEY_CURRENT_USER
             \Software\Microsoft\Windows NT\Current Version\Windows
    
                        
  10. From the Registry menu, click Export Registry File.
  11. In the File Name text box, type c:\Windows.reg.
  12. From the Start button, select Run. Open Devices.reg in Notepad by typing Notepad Devices.reg in Run dialog box.
  13. Replace the text HKEY_CURRENT_USER with HKEY_USERS\.DEFAULT
  14. Save the file. Then import it into the registry by double-clicking the file in Windows Explorer.
  15. Repeat steps 13 through 15 for PrinterPorts.reg and Windows.reg.

These steps only work for local printers.

To enable IIS to enumerate the network printers by using the SYSTEM account, follow these steps.

Note If the process is running under the Network Service account, explicit permissions to the newly created registry are required.

  1. Make sure that you are currently logged in to the server as a user who has the desired network printers installed.
  2. Start Registry Editor.
  3. Click the following key:

    HKEY_CURRENT_USER\Printers\Connections

  4. On the Registry menu, click Export Registry File.
  5. In the File Name box, type c:\printconns.reg.
  6. To open the printconns.reg file in Notepad, click Start, click Run, type Notepad printconns.reg in the Open box, and then click OK.
  7. Replace the text HKEY_CURRENT_USER with the text HKEY_USERS\.DEFAULT.
  8. Save the file.
  9. To import the file into the registry, double-click the file in Windows Explorer.
  10. Restart the Print Spooler service.


REFERENCES

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:




(c) Microsoft Corporation 1998, All Rights Reserved.
Contributions by John Lewis, Microsoft Corporation.


Keywords: kberrmsg kbregistry kbaspobj kbsecurity kbprb KB184291