Jump to content

how to delete and Installing TCP/IP Printer with special configuration


Recommended Posts

Hello,

we will changed nearly other printer,he works with tcp/ip.So il will delete the old one to install the new one.But i go to make this on 70 pc's.So i hope :angel ,to make this with the wipw.But i dont now how to make this. :no:

The new Printer can print forside and backside so i will activated this directly,is this possible?

Thanks,

silver74

Edited by silver74
Link to comment
Share on other sites


@silver74,

Many ways to do this one,

1. Command line option straight from the cmd within wpi or run from bat.

RUNDLL32 PRINTUI.DLL,PrintUIEntry [ options ] [ @commandfile ]

Type "rundll32 printui.dll,PrintUIEntry /?" at the run command or command prompt for more help.

See this link for more info:

PrintUI

2. Run from vbscript

See samples at this link, just piece together the steps you are interested in and use this for your command: "wscript.exe "Your .vbs file here""

Manage Printers via Script

3. See this cool tool from Microsoft, definately a nice tool to have around. Set your Master machine up once, backup those drivers, then restore those defaults to any other system. Silent commands can be found by typing printmig.exe /? at a command prompt.

Print Migrator 3.1

Hope this helps

Edited by lawrenca
Link to comment
Share on other sites

Delete a printer:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * from Win32_Printer where DeviceID = 'ScriptedPrinter'") <-- Change ScriptedPrinted to the friendly name of the printer you want to delete

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

For a printer which the drivers exist in the installed ntprint.inf (part of the windows install)

strComputer = "."

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

set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

'Laserjet 4000

'Installs Printer Driver

objDriver.Name = "HP LaserJet 4000 Series PS" <-- Change to match the driver name in the INF

objDriver.SupportedPlatform = "Windows NT x86"

objDriver.Version = "3"

intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port

objNewPort.Name = "myprinter.mydomain.com" <-- change to match the port name or address

objNewPort.Protocol = 1

objNewPort.HostAddress = "myprinter.mydomain.com" <-- change to match the port name or address

objNewPort.PortNumber = 9100 <-- Change to appropriate port number if needed

objNewPort.SNMPEnabled = True

objNewPort.Put_

'Install Printer

objPrinter.DriverName = "HP LaserJet 4000 Series PS" <-- change to match the driver name in the INF same as first line above

objPrinter.PortName = "myprinter.mydomain.com" <-- name of the port you created above

objPrinter.DeviceID = "My LJ4000" <-- Friendly name displayed in control panel

objPrinter.Location = ""

objPrinter.Network = True

objPrinter.Put_

Install a printer that the driver is NOT in ntprint.inf

strComputer = "."

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

set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP LaserJet 4250 PS" <-- Driver name in INF file

objDriver.SupportedPlatform = "Windows NT x86"

objDriver.Version = "3"

objDriver.FilePath = "C:\\drivers\\lj4250ps\\" <-- Path to inf file

objDriver.Infname = "C:\\drivers\\lj4250ps\\hpc4x50d.inf" <-- Path and name if inf file

intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port

objNewPort.Name = "192.168.1.100" <-- change to the port address or name

objNewPort.Protocol = 1

objNewPort.HostAddress = "192.168.1.100" <-- change to the port address or name

objNewPort.PortNumber = 9100 <-- Change to appropriate port number if needed

objNewPort.SNMPEnabled = True

objNewPort.Put_

'Install Printer

objPrinter.DriverName = "HP LaserJet 4250 PS" <-- change to match the driver name in the INF same as first line above

objPrinter.PortName = "192.168.1.100" <-- change to the port address or name

objPrinter.DeviceID = "My LJ4250" <-- Friendly name displayed in control panel

objPrinter.Location = ""

objPrinter.Network = True

objPrinter.Put_

Save the contents of the appropriate quote above to say add_printer.vbs then double click or add as a startup script or however you want to do it. If needed you can add the delte script and the add scripts into one just don't duplicate the lines that begin with SET that are the same.

Link to comment
Share on other sites

Many thanks to lawrenca and IcemanND :thumbup

If have deleted all mi printers,with the vbs and install my printer via MS Printer migrator from wpiw.It works perfectlyl!!! :thumbup

But only on thing i dont now how to make.I want to save the configuration from the printer with default recto/verso(front-and backside print) and ecomode.

I think is in a regfile but i dont find it, what key must be saved to be after insert . :no:

Somebody can help me? :angel

Link to comment
Share on other sites

@silver74,

The Printer Migration Tool should support multiple configurations for the same printer...just add a printer for each seperate profile/configuration making sure you give them detailed names so you know which is which.

Example:

Port added as standard TCP/IP address, 192.168.1.201
HP5500 PS NetDuplex <--Points to the address above with Duplexing using Postscript Drivers on 8.5x11
HP5500 PCL 6 Net <--Same printer without Duplexing using PCL 6 Drivers on 8.5x11 paper
HP5500 PS Net 11x17 <--Same printer but no Duplexing using Postscript Drivers on 11x17 paper

The key, of course is, you would have to use the Add Printer Wizard, then make sure you have configured the printers and that they are working properly before capturing them with Printer Migration Tool.

Some of the other methods, vbs or printui, you could set these in the command and have a category for Printers with an item corresponding to each printer name, then call those options from the wpi menu...which requires you to know where the drivers are located.

Link to comment
Share on other sites

I have tested these option,but the probleme is.When you install thise these options no be be gone on as default .So you have two printers with the same configuration.

So i will find in what this configuration is storage.Reg,cfg,inf i dont find it.

Can you tell me that?

Link to comment
Share on other sites

  • 4 years later...

Iceman <3 I want your babies hahaha I think using your last option for installing IP ports/drivers/printers I finally have something that works to install stupid HP CLJ 2600n to a load of workstations who can't print via the server anymore because HP won't support that printer on server 2008 x64 and say it's because it's a host based printer (worked fine shared udner 2003 x86!)

Time to test it all out

Oh yes - if there was a way to wrap this up so it was modular and could be called with the ip/name/driverpath for each printer, or at the start of the script it could call a function like that, so that I didn't have to use a seperate vbs for each one, it would be even more killer!

Edited by leozack
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...