Solved

Install Printer Driver via VBS

Posted on 2012-04-13
4
1,428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
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…
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). …

729 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