I’ve already mentioned I work with many customers and servers. Everytime I install a new server that hosts printers I have to handwrite a loginscript that connects/maps the printers on the clients. So I made a template for that as well. There is only a few variables needed to change for it to rock. Check it out.
@echo off
goto start
:start
: Set server name and default printer
set server=ServerName
set default=PrinterShareName1
:Set printer names, according to their share name.
set printvar1=PrinterShareName1
set printvar2=PrinterShareName2
set printvar3=name
set printvar4=name
set printvar5=name
set printvar6=name
: Force to use other drivers than default
set printvar1drv=/ia /f "\\servername\path_to_driver\driver.inf"
set printvar2drv=
set printvar3drv=
set printvar4drv=
set printvar5drv=
set printvar6drv=
: @ to enable, dont forget to set printvar
: rem to disable
set printer1=@
set printer2=@
set printer3=rem
set printer4=rem
set printer5=rem
set printer6=rem
:printer1
if exist "%appdata%\%printvar1%.log" goto printer2
%printer1% RunDll32.exe printui.dll,PrintUIEntry %printvar1drv% /in /Gw /q /n \\%server%\%printvar1% && echo %printvar1% klar >> "%appdata%\%printvar1%.log" && attrib +s +h "%appdata%\%printvar1%.log"
RunDll32.exe printui.dll,PrintUIEntry /in /Gw /q /n \\%server%\%default% /y
goto printer2
:printer2
if exist "%appdata%\%printvar2%.log" goto printer3
%printer2% RunDll32.exe printui.dll,PrintUIEntry %printvar2drv% /in /Gw /q /n \\%server%\%printvar2% && echo %printvar2% klar >> "%appdata%\%printvar2%.log" && attrib +s +h "%appdata%\%printvar2%.log"
goto printer3
:printer3
if exist "%appdata%\%printvar3%.log" goto printer4
%printer3% RunDll32.exe printui.dll,PrintUIEntry %printvar3drv% /in /Gw /q /n \\%server%\%printvar3% && echo %printvar3% klar >> "%appdata%\%printvar3%.log" && attrib +s +h "%appdata%\%printvar3%.log"
goto printer4
:printer4
if exist "%appdata%\%printvar4%.log" goto printer5
%printer4% RunDll32.exe printui.dll,PrintUIEntry %printvar4drv% /in /Gw /q /n \\%server%\%printvar4% && echo %printvar4% klar >> "%appdata%\%printvar4%.log" && attrib +s +h "%appdata%\%printvar4%.log"
goto printer5
:printer5
if exist "%appdata%\%printvar5%.log" goto printer6
%printer5% RunDll32.exe printui.dll,PrintUIEntry %printvar5drv% /in /Gw /q /n \\%server%\%printvar5% && echo %printvar5% klar >> "%appdata%\%printvar5%.log" && attrib +s +h "%appdata%\%printvar5%.log"
goto printer6
:printer6
if exist "%appdata%\%printvar6%.log" goto exit
%printer6% RunDll32.exe printui.dll,PrintUIEntry %printvar6drv% /in /Gw /q /n \\%server%\%printvar6% && echo %printvar6% klar >> "%appdata%\%printvar6%.log" && attrib +s +h "%appdata%\%printvar6%.log"
goto exit
:exit
:eof
exit