Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I install printer and add additional tray under install options using VBS?

Posted on 2008-10-22
2
Medium Priority
?
720 Views
Last Modified: 2012-05-05
My company is getting a new model of Multi-Function-Printers: Lexmark X646e.  I am having to install them on multiple floors for hundreds of people.  I have a VBS install script that installs the printer and uses the latest driver.  There is one problem.  The print driver install does not automatically sense the additional 500 sheet trays Installed with the printer.

You can manually add the additional tray on each PC via the "Install Options" tab under printer properties, but I would like to have this done automatically through the script.

These are Windows XP Pro clients, SP2.  I have attached my current code.  

Any Ideas?
'Option Explicit
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
 
'**************************************
'* Define Constants & Global Variables
'**************************************
Dim objDomainUser, objNetwork, objShell, strComputer, colDrives, i
Dim objWMI, objNewPort, strPrinterHost, strPrinterName, strPrinterDriver, strUserName, strPrinterDriverLocation, strPrinterDriverInfFile
 
 
 
'
 
'****Printer Lexmark646e*****************
Strcomputer ="."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
objWMI.Security_.Privileges. _
    AddAsString "SeLoadDriverPrivilege", True
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer where DeviceID = 'PrinterLX'")                                                                                             
For Each objPrinter in colInstalledPrinters 
objPrinter.Delete_
Next
' Put the hostname of the printer here
strPrinterHost = "PrinterLX"
' Put the name of the printer here
strPrinterName = "PrinterLX"
Set objShell = CreateObject("WScript.Shell")
' Create the printer port
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
objWMI.Security_.Privileges. _
    AddAsString "SeLoadDriverPrivilege", True
Set objNewPort = objWMI.Get("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & strPrinterHost
objNewPort.Protocol = 1
objNewPort.HostAddress = strPrinterHost
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_
 
 
objshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b ""PrinterLX""" & " /f " & """\\ServerShare\Printers\prdrivers\lexmarkx646\win_2kxp\LMABC2DA.INF""" & " /r " & """ip_PrinterLX""" & " /m " & """Lexmark X646e""",,True
 
 
'

Open in new window

0
Comment
Question by:marktgeorge
[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 Comments
 

Accepted Solution

by:
marktgeorge earned 0 total points
ID: 22991271
I figured it out with the help of the lexmark provided utility that automates installs using the proprietary lexmark install software scripts.  However I will say it is much simpler to administer and change when using a blend of the two (use vbs to create printer and printer ports and use lexmark for driver customization).  You can call the lexmark utility from your vbs scripts.  However, there are some shortcomings on the switches used by lexmark's executable.  Yes, the lexmark utility also allows for remote installs on multiple pcs, but it requires hard coded username and password for install rights.  In my organization, that is not an option - perversely strict security requirements!
0
 

Author Comment

by:marktgeorge
ID: 22991328
Use the above code to create the printer object and port, then call Lexmarks install utility(in the vbs code) and Lexmark custom created answer file to install the customized driver complete with tray and other add-on options you specified.   The Lexmark software will come with the printer.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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