Wednesday, March 20, 2013

Set default printer for each subnet network location




:check version
ver | find "6." > nul
if %ERRORLEVEL% == 0 goto ver_win7

ver | find "5." > nul
if %ERRORLEVEL% == 0 goto ver_xp

GOTO VERERROR

:VERERROR
ECHO Error finding OS version
GOTO END

:ver_xp
ipconfig | find /i "IP Address" | find /i "172.20.15" && GOTO 15thFloor
ipconfig | find /i "IP Address" | find /i "172.20.16" && GOTO 16thFloor
GOTO ERROR

:ver_win7
ipconfig | find /i "IPv4 Address" | find /i "172.20.15" && GOTO 15thFloor
ipconfig | find /i "IPv4 Address" | find /i "172.20.16" && GOTO 16thFloor
GOTO ERROR

:15thFloor
Rundll32.EXE printui.dll,PrintUIEntry /y /q /n "\\ServerName\PrinterNAME"
GOTO END

:16thFloor
Rundll32.EXE printui.dll,PrintUIEntry /y /q /n "\\ServerName\PrinterNAME"
GOTO END

:ERROR
ECHO Error finding IP Address
GOTO END

:END