Solved

Install Printer Driver via VBS

Posted on 2012-04-13
4
1,425 Views
Last Modified: 2012-04-21
Hi,
I should write a VBS-script which installs first a printer driver and after that installs a printer with this driver on WinXP. Installing  the printer with a driver which is already installed works but when I want to use the inf file of the print driver I want to install  I get always an error

"
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k --> Install printer DRIVER
objShell.Run "%comspec% /k rundll32 printui.dll,PrintUIEntry /if /b ""PrinterName"" /f %windir%\inf\ntprint.inf /r ""Port"" /m ""HP Color LaserJet 2800 Series PS"" &" 
WScript.Quit
' End of Example ComspecDir VBScript
"



-> The driver is located in the folder: \driver\
0
Comment
Question by:skiaholic
  • 2
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 37849627
What kind of error do you get?  If the driver is unsigned, it won't install silently, and will require you to click "Continue".

This line will error:
objShell.Run "%comspec% /k --> Install printer DRIVER

as it's not required.  This line wont need the & on the end.
objShell.Run "%comspec% /k rundll32 printui.dll,PrintUIEntry /if /b ""PrinterName"" /f %windir%\inf\ntprint.inf /r ""Port"" /m ""HP Color LaserJet 2800 Series PS"" &" 

Try this. It's not much different, but should work.  Your inf file should be in the same folder as the relevant printer driver:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k rundll32 printui.dll,PrintUIEntry /if /b ""PrinterName"" /f %windir%\inf\ntprint.inf /r ""Port"" /m ""HP Color LaserJet 2800 Series PS"""

Open in new window


Regards,

Rob.
0
 

Accepted Solution

by:
skiaholic earned 0 total points
ID: 37850520
Thanks RobSampson.
The problem was not only the printer driver. The problem was also the local port.  I have solved it that way:


Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k  reg add ""HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports"" /v  portname /t REG_SZ /f & net stop spooler & net start spooler & rundll32 printui.dll,PrintUIEntry /if /b ""printername"" /f %windir%\inf\ntprint.inf /r ""portname"" /m ""Apple Color LW 12/660 PS"" &" 
WScript.Quit
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37853767
OK cool. Glad you got it sorted.

Rob.
0
 

Author Closing Comment

by:skiaholic
ID: 37875008
you must also add first a local port in registry if you want to use a "Redirected Port"
0

Featured Post

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question