Hallo, Here my change version of the script from Glenn, But I can't get it to work in my domain. My domain consist of 3 subnet 1 main office and 2 branch, all the printers are installed on the print server witch is on the main serverpark at the main branch. But none of the pc's are getting the printers installed. Can someone help. maybe I'm overlooking an error.
 Code:
$Networks = '10.50.0.0/22','10.50.20.0/22','10.50.24.0/22'
$Printers = '\\GL050-PRN-001\OLA-Printer001','\\GL050-PRN-001\OLA-Printer002','\\GL050-PRN-001\OLA-Printer003'
$Mapped = 0

$MyIP = Join(Split(@IPADDRESS0, ' '), '')

For $I = 0 to UBound($Networks)
  If InSubnet($MyIP, $Networks[$I])
    'My ip address (' $MyIP ') exists in network $I (' $Networks[$I] ')' ?
    'Mapping printer ' $Printers[$I] ?
    $Mapped = 1
  EndIf
Next

If Not $Mapped
  'No printers were mapped!' ?
EndIf

Function InSubnet($_IPAddr, $_Network)

  Dim $_aAdd				; array of address values
  Dim $_Mask				; Mask value
  Dim $_Hosts				; hosts in subnet

  ; Convert the supplied IP address to a double value representing the decimal address
  $_aAdd = Split($_IPAddr, '.')
  $_IPAddr = (CDbl($_aAdd[0]) * 16777216.0) + (CDbl($_aAdd[1]) * 65536.0) + (CDbl($_aAdd[2]) * 256.0) + (CDbl($_aAdd[3]) * 1.0)

  ; Convert the network from a w.x.y.z/mask format to a decimal value
  ; this is the starting network address value
  $_Network = Split($_Network, '/')
  $_Mask = Val($_Network[1])
  $_aAdd = Split($_Network[0], '.')
  $_Network = (CDbl($_aAdd[0]) * 16777216.0) + (CDbl($_aAdd[1]) * 65536.0) + (CDbl($_aAdd[2]) * 256.0) + (CDbl($_aAdd[3]) * 1.0)

  ; Set the number of hosts in the defined network
  $_Hosts = 1.0
  For $_I = 31 to $_Mask Step -1
    $_Hosts = ($_Hosts * 2.0)
  Next

  ; return the value 
  $InSubnet = 0
  If $_IPAddr >= $_Network And $_IPAddr < ($_Network + $_Hosts)
    $InSubnet = 1
  EndIf



EndFunction


Edited by NTDOC (2009-01-19 09:00 PM)
Edit Reason: Added CODE TAGS