Solved

How do I include printer settings in a Printer Install VBS?

Posted on 2010-11-23
3
687 Views
Last Modified: 2012-05-10
I have a VBS that deletes an old printer and installs a new Printer, Port, and Driver.  I would like to include in the script some default settings for the printer being installed.  I would like it to default to "Black and White" and to print Duplex.  I had read about using 'PrinterObject', but wasn't sure about how to include it in this script. In the code I am providing as an example , it is deleting a printer named ADPCMFD01 and installing a new one named DOEMFD01.  
'******** Delete old Printer *******
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer where DeviceID = 'ADPCMFD01'")

For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer where DeviceID = 'ADPCMFD01 Fax'")

For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort Where Name = 'ADPCMFD01'")

For Each objPort in colInstalledPorts 
    objPort.Delete_
 
Next

'******** Register prnadmin.dll file on client computer *******

Set WshShell = Wscript.CreateObject("Wscript.Shell")

WshShell.Run "regsvr32 /s \\SERVER\tools\Prnadmin.dll",1,TRUE




'************** Create the port first *******************************

dim oPort

dim oMaster

set oPort = CreateObject("Port.Port.1")

set oMaster = CreateObject("PrintMaster.PrintMaster.1")

oPort.PortName = "DOEMFD01"

oPort.PortType = 2  'The type of the port can be 1 (TCP RAW), 2 (TCP LPR), or 3 (standard local)

oPort.HostAddress = "10.36.20.37"

oMaster.PortAdd oPort

If Err <> 0 then

msgbox "There was an error creating the printer."




end if



'********************************************************************

'************** Create the printer second ***************************




dim oPrinter

set oPrinter = CreateObject("Printer.Printer.1")

oPrinter.PrinterName = "DOEMFD01 Savin c4040"		' name of the printer as it appears in the Printers folder

oPrinter.DriverName = "SAVIN C3333 PCL 6"		' name that is referenced in ntprint.inf

oPrinter.PortName = "DOEMFD01"		' Specify a port name. Can also point to LPT or COM port.

oPrinter.DriverPath  = "\\SERVER\PrinterSetup\Drivers\Savin\s46603en\disk1"     'Folder to where the drivers are

oPrinter.InfFile     = "\\SERVER\PrinterSetup\Drivers\Savin\s46603en\disk1\OEMSETUP.INF"     ' Where is my .inf file

oMaster.PrinterAdd oPrinter



oPrinter.PrinterName = "DOEMFD01 FAX"		' name of the printer as it appears in the Printers folder

oPrinter.DriverName = "LAN-Fax M8"		' name that is referenced in ntprint.inf

oPrinter.PortName = "DOEMFD01"		' Specify a port name. Can also point to LPT or COM port.

oPrinter.DriverPath  = "\\SERVER\PrinterSetup\Drivers\Savin\c4040\fax driver\Fax Driver including inf"     'Folder to where the drivers are

oPrinter.InfFile     = "\\SERVER\PrinterSetup\Drivers\Savin\c4040\fax driver\Fax Driver including inf\PRINTER.INF"     ' Where is my .inf file


oMaster.PrinterAdd oPrinter

Open in new window

0
Comment
Question by:ODOTSupport
[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
3 Comments
 
LVL 43

Accepted Solution

by:
Davis McCarn earned 125 total points
ID: 34204864
The problem is that those settings are going to be different for each model (much less make) of printer and my best suggestion is to either use the WshShell.RegWrite functions if the registry changes are trivial or to export the settings after you have set them and then merge the resultant .REG file.
RegWrite: http://www.devguru.com/technologies/wsh/quickref/wshshell_RegWrite.html
Utility to snapshot and find registry changes: http://majorgeeks.com/RegSnap_d532.html
0
 
LVL 38

Expert Comment

by:hdhondt
ID: 34456663
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Schedule a Tour of the ATEN booth at InfoComm 2017

Tour the ATEN booth to see the the Latest Addition to the Modular Matrix Switch Series, New 4K HDMI Over IP Extender and more! Enter ATEN's Ultimate Giveaway Sweepstakes for a chance to win one of several great prizes, including an ATEN US7220 2-Port Thunderbolt 2 Sharing Switch!

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

696 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