Announcement

Collapse
No announcement yet.

Problem with Printer IP re-allocation Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with Printer IP re-allocation Script

    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?

    [Moderator EDIT: "Added [code] tags", \Rems]
    Code:
    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\Monitors\Standard TCP/IP Port\Ports\"
                  print4 = print3 & Printers.Item(i) & "\"
                  print5 = "HKLM\system\CurrentControlSet\Control\Print\Printers\" & 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 effect."
    Last edited by Rems; 17th September 2008, 19:10.

  • #2
    Re: Problem with Printer IP re-allocation Script

    TONYH you posted the same question again in the GPO forum at the end of the same day, No double posting !!
    Read the forum rules before you post.
    http://forums.petri.com/announcement.php?f=26

    Double Post is deleted from the GPO forum.

    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X