''----------------------------------------------''
''----------------------------------------------''
'' ''
'' Script to automate TCP/IP printer installs ''
'' (Andrew Levine - 12/2004) ''
'' ''
''----------------------------------------------''
''----------------------------------------------''
''----------------NA PODSTAWIE------------------''
''http://www.tek-tips.com/viewthread.cfm?qid=973606&page=3''
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:'
'------------------'
'---HP 3005---'
createPort "IP_192.168.160.96", "192.168.160.96"
'---HP 2015---'
createPort "IP_192.168.160.73", "192.168.160.73"
'-------------------------------------------------' Display name
'Install printers with externally defined drivers:' for printer Driver location Port name Driver name in .inf file
'-------------------------------------------------' ----------- --------------------------------- ------------ -----------------------
'-------------------------------------------------'
'HP 3005'
'-------------------------------------------------'
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set objPrinters = objNetwork.EnumPrinterConnections
drukarka = "HP 3005"
Install_Printer = 1
For Loop_Counter = 0 To objPrinters.Count -1 Step 2
If objPrinters.Item(Loop_Counter+1)=drukarka then Install_Printer = 0
Next
If Install_Printer = 1 Then
oshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b ""HP 3005 Inwestycje"" /f \\filesrv1\Serwis\Sterowniki\Drukarki\HPLJ3005\Win32_2000_XP_S2003\PCL5v6.1\hpc300xb.inf /r ""IP_192.168.160.96"" /m ""HP LaserJet P3005 PCL 5e""" ,,true
End If
'-------------------------------------------------'
'HP 2015'
'-------------------------------------------------'
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set objPrinters = objNetwork.EnumPrinterConnections
drukarka = "HP 2015"
Install_Printer = 1
For Loop_Counter = 0 To objPrinters.Count -1 Step 2
If objPrinters.Item(Loop_Counter+1)=drukarka then Install_Printer = 0
Next
If Install_Printer = 1 Then
oshell.run "RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b ""HP 2015 BHP"" /f \\filesrv1\Serwis\Sterowniki\Drukarki\HPLJ2015\PCL5\hppcp504.inf /r ""IP_192.168.160.73"" /m ""HP LaserJet P2015 Series PCL 5""" ,,true
End If
'----------------------------------------------'
'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"
msgbox ("Instalacja drukarek zakończona powodzeniem :)")
Brak komentarzy:
Prześlij komentarz