Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui

Don't forget to reboot after running script!

Adding Printer:

@CLS

::CMD to use to add Printer::

:/in	Connects to a remote network printer.
:/ga	adds a per computer printer connection (the connection is available to any user on that computer when they log on).
:/n[name]	Specifies the printer name.
:https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui

set PRINTUI=rundll32 printui.dll PrintUIEntry /in /ga /n

set SERVER=SERVER

set DOCPRNTR=PRINTER

%PRINTUI% \\%SERVER%\%DOCPRNTR%

::Final Steps::
echo "You MUST reboot computer to complete printer installation"
echo "After reboot run 'Set_Default_Printer.cmd'"
PAUSE

Removing Printer:

@CLS

::CMD to use to add Printer::

:/gd	deletes a per computer printer connection (the connection is deleted the next time a user logs on).
:/dn	deletes a network printer connection.
:/dl	deletes the local printer.
:/n[name]	Specifies the printer name.
:https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui

set PRINTUI=rundll32 printui.dll PrintUIEntry /dn /gd /n

set SERVER=SERVER

set DOCPRNTR=PRINTER

%PRINTUI% \\%SERVER%\%DOCPRNTR%

::Final Steps::
echo "You MUST reboot computer to complete printer un-installation"
pause

Saving & Restoring Printer Settings (This is the best I could find for setting up Printer via CLI, basically set it up manually, then export settings for future import):


/Ss = Save
/Sr = Restore

::Saving
set PRINTUI=rundll32 printui.dll PrintUIEntry /Ss /n
set SERVER=SERVER
set DOCPRNTR=PRINTER

%PRINTUI% "\\%SERVER%\%DOCPRNTR%" /a "%USERPROFILE%\Downloads\%DOCPRNTR%.dat"

::Restoring ' Note the u Flag!
pushd %~dp0
@CLS

set PRINTUI=rundll32 printui.dll PrintUIEntry /Sr /n
set SERVER=SERVER
set DOCPRNTR=PRINTER

::Add Printers::
%PRINTUI% \\%SERVER%\%DOCPRNTR% /a "%~dp0%DOCPRNTR%.dat" u
  • No labels