Mapping a printer by way of a subnet or ipaddress
Posted on 2007-04-02
I have two servers. One on 192.168.1.x and 192.168.2.x. Each server is in a different location. I need to create a login script that will map the appropriate printer for the ip address. For example, a client logs in at one location and gets a printer, currently, and then, if they go to the other location that printer is still there. I need to make it so it adds the printer for that location ONLY so they wont be printing to the wrong location. In addition, I need to make that the printer default.
Here is the script that another person here helped me out with.
However, it is still not working.
I continue to get a UNC path error if I try running it from using explorer to the server.
I get no error, if I run it from a shortcut on the desktop, but it still will not work.
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find "IP Address"') do set IP ADDR=%%a
for /f "tokens=1,2,3 delims=." %%a in ("%ipaddr%") do set SUBNET=%%a.%%b.%%c
if "%subnet%"=="192.168.1" goto subnet1
if "%subnet%"=="192.168.2" goto subnet2
echo On another subnet (%subnet%)
echo Running on subnet 1 (%subnet%) from %ipaddr%
rundll32 printui.dll,PrintUIEntry /dn /n \\saco\HP4200
rundll32 printui.dll,PrintUIEntry /in /n /y \\lewiston-server\HP4200
echo Running on subnet 2 (%subnet%) from %ipaddr%
rundll32 printui.dll,PrintUIEntry /dn /n \\lewiston-server\HP4200
rundll32 printui.dll,PrintUIEntry /in /n /y \\saco\HP4200
the "lewiston-server" and "Saco" are Windows 2000 Servers
and the logon script is on a shared folder of a Windows2003 server