Solved

Install Printer Driver via VBS

Posted on 2012-04-13
4
1,415 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
Comment Utility
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
Comment Utility
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
Comment Utility
OK cool. Glad you got it sorted.

Rob.
0
 

Author Closing Comment

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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). …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now