Microsoft KB Archive/297454

= PRB: You Receive Error Message If You Use AddWindowsPrinterConnection Method to Add Printers Using Windows Script Host File =

Article ID: 297454

Article Last Modified on 8/8/2007

-

APPLIES TO


 * Microsoft Windows Scripting Host 2.5
 * Microsoft Windows Scripting Host 2.5

-



This article was previously published under Q297454



SYMPTOMS
If you try to use the AddWindowsPrinterConnection method to add printers to Microsoft Windows 95, Microsoft Windows 98, or Microsoft Windows Millennium Edition (Me) clients, you may receive one of the following errors messages:

Error: 80070705 The printer driver is unknown.

-or-

Error: 8007070A The printer already exists.



CAUSE
This behavior can occur in Windows Script Host if either of the following conditions are true:

 The printer driver is not installed when you use the AddWindowsPrinterConnection method in a script.

-or-

 Two or more installed printers use the same printer driver. The AddWindowsPrinterConnection method uses the printer driver name for the printer name.



RESOLUTION
There is no script workaround for either problem. However, you can use a custom Component Object Model (COM) or Win32 Dynamic-link Library (DLL) to resolve this problem.

Win32 DLLs allow the script to run on a local computer and reference the DLL on a remote share. This is very helpful in the case of a login script, where thousands of clients need to use the DLL but the administrator does not want to deploy the DLL. Samples of Win32 DLLs have been tested in scenarios that resulted in the error messages listed in the &quot;Symptoms&quot; section. For more information on these tests, see the &quot;References&quot; section.



STATUS
This behavior is by design.



MORE INFORMATION
To install a printer driver for Microsoft Windows 2000 or Microsoft Windows NT 4.0, the command line utility Rundll32.exe can be used.

For additional information about how to use Rundll32.exe, click the article number below to view the article in the Microsoft Knowledge Base:

164787 INFO: The Windows 95 Rundll and Rundll32 Interface

Below is a sample script using Rundll32.exe: Dim WshShell

Set WshShell = CreateObject(&quot;WScript.Shell&quot;) Wshell.Run &quot;RunDLL32 <\\server\share\drvsrv,Install> &quot;<\\server\share>&quot;, 1, True Set WshShell = Nothing

Steps to Reproduce Behavior
To reproduce error 80070705, follow these steps:  Replace &quot;<\\server\share>&quot; with a printer share on your network. Verify that the printer installed is not connected to the specified driver.</li>  Run the following sample code. Dim WshNetwork

On Error Resume Next Set WshNetwork = CreateObject(&quot;WScript.Network&quot;) PrinterPath = &quot;<\\server\share>&quot; PrinterDriver = &quot;Lexmark Optra S 1650&quot; Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath, PrinterDriver, PrinterPath) If Not rc then WScript.Echo(&quot;Printer Connection Failed!&quot;) End If                   </li></ol>

To reproduce error 8007070A, follow these steps: <ol> Replace &quot;<\\server\share>&quot; with a printer share on your network.</li> Verify that the printer installed is connected to the specified driver and the printer name is the same as the driver name.</li>  Run the following sample code. Dim WshNetwork

On Error Resume Next Set WshNetwork = CreateObject(&quot;WScript.Network&quot;) PrinterPath = &quot;<\\server\share>&quot; PrinterDriver = &quot;Lexmark Optra S 1650&quot; Set rc = WshNetwork.AddWindowsPrinterConnection(PrinterPath, PrinterDriver, PrinterPath) If Not rc then WScript.Echo(&quot;Printer Connection Failed!&quot;) End If                   </li></ol>

<div class="references_section">