2009/09/03

Bruce's Printing Pages

Bruce's Printing Pages
Also one other helpful page
Another nice page that discusses adding a network printer for all users on a computer, whether they already have a profile or not. Here's an example script that will prompt you for your location (if you have multiple servers) or if you are using a windows shared printer and adds it. Please credit me if you use parts of this script.

@ECHO OFF

REM Last edited 9:26 AM 5/9/2007
REM Created by Sean A. Flesch
REM 585-262-1715
REM Monroe Community College
REM sflesch@monroecc.edu
REM
REM Add or remove a network printer, including
REM a shared printer from a PC, for ALL
REM users of a PC, even future users
REM
REM This is helpful for re-imaged PCs with
REM multiple users who cannot all be setup
REM at the same time
REM


set campus=
set server=
set pname=
set action=
set complete=

:getaction
cls

SET /P action=[Are you Adding or Removing a printer? (A/R)]
if '%action%'=='A' goto getlocation
if '%action%'=='a' goto getlocation
if '%action%'=='R' goto getlocation
if '%action%'=='r' goto getlocation
goto getaction

:getlocation
ECHO .
ECHO You are about to add a network printer for all users of this pc
ECHO .
ECHO B - Brighton
ECHO D - Damon
ECHO L - A printer that is installed locally on another PC and shared
ECHO .
ECHO .
ECHO *** If you are connecting to a Printer installed locally on another PC ***
ECHO *** there can be no spaces in the share name ***
ECHO .
ECHO .
ECHO .

SET /P campus=[Please choose Brighton or DCC or Local (B/D/L)]
if '%campus%'=='b' goto B150
if '%campus%'=='B' goto B150
if '%campus%'=='d' goto D150
if '%campus%'=='D' goto D150
if '%campus%'=='L' goto Decal
if '%campus%'=='l' goto Decal
goto getlocaction

:B150
set server=MCC-B150
goto getprint

:D150
set server=MCC-D150
goto getprint

:Decal
ECHO .
ECHO .
set /P server=[Computer Name where shared printer is]
if '%server%'=='' goto Decal

:localshare
ECHO .
ECHO .
SET /P pname=[Printer Name as shared from that PC]
if '%pname%'=='' goto localshare
goto checkaction

:getprint
ECHO .
ECHO .
SET /P pname=[Printer Name eg P-30-5106-01]
goto checkaction

:checkaction

if '%action%'=='A' goto addprinter
if '%action%'=='a' goto addprinter
if '%action%'=='R' goto removeprinter
if '%action%'=='r' goto removeprinter
goto getaction

:addprinter

ECHO .
ECHO .
SET /P confirm=[Please confirm you wish to add PRINTER %pname% from SERVER %server% to all users (Y/N)]
if '%confirm%'=='Y' goto confirmedadd
if '%confirm%'=='y' goto confirmedadd
if '%confirm%'=='N' goto getaction
if '%confirm%'=='n' goto getaction
goto addprinter

:confirmedadd

RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /ga /n\\%server%\%pname%
ECHO Printer was added - restarting services.
ECHO .
goto finish

:removeprinter

ECHO .
ECHO .
SET /P confirm=[Please confirm you wish to remove PRINTER %pname% from SERVER %server% to all users (Y/N)]
if '%confirm%'=='Y' goto confirmedremove
if '%confirm%'=='y' goto confirmedremove
if '%confirm%'=='N' goto getaction
if '%confirm%'=='n' goto getaction
goto removeprinter

:confirmedremove

RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /gd /n\\%server%\%pname%
ECHO Printer was removed - restarting services.
ECHO .
goto finish

:finish
sc stop spooler
sc start spooler

ECHO You may have to refresh your printer folder to see
ECHO the new printer
ECHO .
ECHO .
ECHO If you received a windows error, the printer name was
ECHO probably not entered correctly
ECHO .
ECHO .

set /P complete=[All done? (Y/N)]
if '%complete%'=='Y' goto end
if '%complete%'=='y' goto end
if '%complete%'=='N' goto getaction
if '%complete%'=='n' goto getaction

:end

No comments: