Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting Printers Via IP, installing drivers, creating ports, etc

Status
Not open for further replies.
Sep 3, 2012
1
0
0
US
Hello,

I know several people have asked similar questions and I'm sure everyone is tired of how do I script printers but I need a bit of help.

Environment: Mixed DCs and mixed clients from xp to 7 64 bit. 4 new Scanner/Copiers mapped via IP. I have the 4 IPs and printer names.

Request: I'd like a functioning script if possible unfortunately my deadline to figure this out is very soon. Any and all help is appreciated. Thank you.

So I have some stuff I found that I may be able to use but probably need to edit drastically.

' Add a Printer Connection

Set WshNetwork = CreateObject("WScript.Network")
//There should be a check to see if the printers are already installed here.

{ //I need to run this section 4 times to add 4 ports. Adds ports.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_192.168.200.225" //It will be 225, 226, 227, 228
objNewPort.Protocol = 1
objNewPort.HostAddress = "192.168.200.225"
objNewPort.PortNumber = "9999" //I don't know what port this is supposed to be? Is this the standard printer port or port # on pc?
objNewPort.SNMPEnabled = False
objNewPort.Put_
}

{ //Adds printer drivers
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("TASKalfa 5550ci") //This is the exact name of the printer but not sure if this is the driver.

objDriver.Name = "Kyo Color 1" //Needs 1 2 3 4
objDriver.SupportedPlatform = "Windows NT x86" //This needs to support xp, windows 7/vista 32/64
objDriver.Version = "3"
objDriver.DriverPath = "C:\Scripts\NewPrinter.dll" //This will be hosted on \\tr-srv\pdrivers
objDriver.Infname = "C:\Scripts\NewPrinter.inf" //tbd
intResult = objDriver.AddPrinterDriver(objDriver)
}

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

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

objPrinter.DriverName = "Kyo Color 1"
objPrinter.PortName = "IP_192.168.200.225"
objPrinter.DeviceID = "ScriptedPrinter"
objPrinter.Location = "USA/Redmond/Building 37/Room 114"
objPrinter.Network = True
objPrinter.Put_
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top