Solved

Install Printer Driver via VBS

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
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…
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…

635 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