views:

1375

answers:

3

I'm working on a script that needs to set up a Xerox Phaser printer using the postscript driver. The computers currently have the PCL driver on them (though the printers aren't set up on them yet.) I want to install the PS driver using the specified INF, and then install the printer using the driver provided after the INF is installed (so as not to accidentally use the PCL driver.) How can I accomplish this in VBScript?

+2  A: 

Here's an example on how to do that: VBScript Install Printer

Edit: For a local printer, make the following changes to the script

oPort.PortName = "LPT1:"
oPort.PortType = 3

And remove the oPort.HostAddress line

Jose Basilio
Nice google-fu! +1
ichiban
I don't want to create an IP printer, but configure it to use the parallel port, would that change anything in the script?
Jordan Milne
I included the changes to the script in my Edit
Jose Basilio
The first solution requires the [Windows Server 2003 Resource Kit](http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd However, some people may want to do something more like [this](http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/8270955345?r=2210975345#2210975345) since it will work on the default install of windows.
Jordan Milne
A: 

You may want to take a look at using the rundll32 InstallHinfSection Function. That is how I do it. It doesn't require you install any extra ActiveX component. There is a example for how to use it here: http://www.msfn.org/board/Silent-parameters-for-RunDll32-setupapi-t106711.html Basically its, %systemroot%\system32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 C:\drivers\2100\PCL 5e\hp211ip5.inf

You may also want to take a look at the PrintUIEntry function, as this will allow you to add the printer if the drivers are already loaded on a system. See here fore further info: http://support.microsoft.com/kb/189105

mrTomahawk
+1  A: 

I always revert to the following links to install printers 'programatically'.

http://support.microsoft.com/kb/314486

http://www.robvanderwoude.com/2kprintcontrol.php

Douglas Anderson