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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to install TCP/IP Printers

Status
Not open for further replies.

secutanudu

IS-IT--Management
Oct 6, 2004
138
US
Hopefully someone will get as much use out of this as I did....


''----------------------------------------------''
''----------------------------------------------''
'' ''
'' Script to automate TCP/IP printer installs ''
'' (Andrew Levine - 12/2004) ''
'' ''
''----------------------------------------------''
''----------------------------------------------''


Set WSHNetwork = WScript.CreateObject("WScript.Network")
set shell = WScript.CreateObject( "WScript.Shell" )
CompName = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set objWMIService = GetObject("winmgmts:\\" & CompName & "\root\cimv2")
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
Set oShell = WScript.CreateObject("WScript.shell")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

sub createPort (name, ip)
objNewPort.Name = name
objNewPort.Protocol = 1
objNewPort.HostAddress = ip
objNewPort.SNMPEnabled = False
objNewPort.Put_
end sub

sub addPrinter (driver, port, name)
objPrinter.DriverName = driver
objPrinter.PortName = port
objPrinter.DeviceID = name
objPrinter.Location = "CEH"
objPrinter.Network = True
objPrinter.Shared = false
objPrinter.ShareName = ""
objPrinter.Put_
end sub

message = "Please choose a printer to install:" & vbCrLf & vbCrLf & "1: All Printers" & vbCrLf & "2: HP4200 North" & vbCrLf & "3: HP8150 South" & vbCrLf & "4: HP8500 Color PS" & vbCrLf& vbCrLf & vbCrLf & "Please enter 1-5 (leave blank to quit):"
title = "Install Printers - BCEHFP"

'------------------'
'Add printer ports:'
'------------------'
'createPort "HP8150_BCEHFP_South", "150.142.154.159"
'createPort "HP4200_BCEHFP_North", "150.142.155.50"
'createPort "HP8500_Exec_color", "150.142.153.21"

'----------------------------------------------'
'Install printers with drivers native to WinXP:'
'----------------------------------------------'
' TCP/IP Port Name Display Name
' -------------------- -----------------
'addPrinter "HP Color LaserJet 8500 PS", "HP8500_Exec_color", "HP8500 Color PS"
'addPrinter "HP LaserJet 4200 PS", "HP4200_BCEHFP_North", "HP4200 North PS"
'addPrinter "HP LaserJet 4200 PCL 6", "HP4200_BCEHFP_North", "HP4200 North"

'-------------------------------------------------' Display name
'Install printers with externally defined drivers:' for printer Driver location Port name Driver name in .inf file
'-------------------------------------------------' ----------- --------------------------------- ------------ -----------------------
'oshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b ""HP8150 South"" /f U:\instalxp\hp8150\HP8150_6.INF /r ""HP8150_BCEHFP_South"" /m ""HP LaserJet 8150 PCL 6""" ,,true
'oshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b ""HP8150 South PS"" /f U:\instalxp\hp8150ps\HP8150PS.INF /r ""HP8150_BCEHFP_South"" /m ""HP LaserJet 8150 PS""" ,,true



msgbox ("Printer installation complete.")
 
This will look a lot cleaner in a text editor...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top