Huh??? Did you actually try the script? Copy my script and paste it into "test.kix" - then run it. DO NOT make any changes.. It will tell you that no printers were mapped.

Next, change one of the entries on the third line to represent YOUR local subnet. IE: if your IP is 192.168.15.17, and your mask is 255.255.255.0, then the line
$Networks = '10.1.0.0/24','10.18.22.0/24','10.64.61.0/24'
becomes
$Networks = '10.1.0.0/24','192.168.15.0/24','10.64.61.0/24'
(I picked the second network arbitrarily)

Run the script again - it should say \\server\printer2 was mapped. That's because the function that it called determined that 192.168.15.17 is in the 192.168.15.0 network - it matched the first 3 octets.

Basically, $Networks is a list of each network addresses and mask in CIDR format. $Printers is a list of printer shares. You need to create the list of networks that match your environment, and create the Printers list in the same sequence.

The way my script works is it determines the IP address of the client where the script is running. It then loops through the list of networks, comparing the local IP with the network/mask values. This is how you determine if an IP address is in a network.

You need to understand basic network/netmask concepts if you expect to make any of this work. The CIDR format represnts the number of bits in the netmask. As I said in my first post, it's a simple solution requiring no logic on your part - just define the array of networks and printer shares, and add the code to actually perform the printer mapping. (basically - you need to replace these lines:
 Code:
    'My ip address (' $MyIP ') exists in network $I (' $Networks[$I] ')' ?
    'Mapping printer ' $Printers[$I] ?

with the commands to map the printer defined by $Printers[$I].

Try it and see if the example works for you. If it does, we can work on making the list of networks/printers easier to manage.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D