Solved

Install Printer Driver via VBS

Posted on 2012-04-13
4
1,423 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It started not too long ago. It was at first annoying. My keystrokes seemed to be randomly generated, not the ones I typed on the keyboard. For some reason this only happened in certain applications (especially browsers such as IE11, Firefox and Chr…
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 …
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…

856 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