tonyh
Posts: 1
Score: 0 Joined: 9/17/2008 Status: offline
|
The following scripts works fine with admin rights, won’t work with-out. I tried to apply a registry fix to elevate the rights with GP but was unsuccessful. The CSV file contains the IP address of the new printer, old Printer Thoughts? Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set Printers = WshNetwork.EnumPrinterConnections For i = 0 to Printers.Count - 1 step 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("c:\printerIP.txt", 1) Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.Readline arrServiceList = Split(strNextLine , ",") ip = arrServiceList(1) newip = arrServiceList(0) if Printers.Item(i) = "IP_" & ip then print1 = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\" & printers.item(i+1) & "\" print2 = print1 & "DsSpooler\" print3 = "HKLM\system\CurrentControlSet\Control\Print\Monit ors\Standard TCP/IP Port\Ports\" print4 = print3 & Printers.Item(i) & "\" print5 = "HKLM\system\CurrentControlSet\Control\Print\Print ers\" & printers.item(i+1) & "\" print6 = print5 & "DsSpooler\" WScript.Echo "Printer " &Printers.Item(i+1) &" has been updated. Please restart your system" WSHShell.RegWrite print1 & "Port", "IP_" & newip WSHShell.RegWrite print2 & "PortName", "IP_" & newip WSHShell.RegWrite print5 & "Port", "IP_" & newip WSHShell.RegWrite print6 & "PortName", "IP_" & newip WSHShell.RegWrite print3 & "IP_" & newip & "\" &"HostName", "" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"HWAddress", "" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"IPAddress", newip WSHShell.RegWrite print3 & "IP_" & newip & "\" &"PortNumber", "9100", "REG_DWORD" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"Protocol", "1", "REG_DWORD" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"SNMP Community", "public", "REG_SZ" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"SNMP Enabled", "1", "REG_DWORD" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"SNMP Index", "1", "REG_DWORD" WSHShell.RegWrite print3 & "IP_" & newip & "\" &"Version", "1", "REG_DWORD" end if Loop next 'WScript.Echo " Your Printers have been updated. A reboot is required before changes will take
|