Add printer configuration to printer management. i.e. a sharp copier that requires you to manually click auto configuration for the printer to update it’s settings to match the printer.
I already have this scripted and imagine it would be pretty easy to add to the existing printer management. I would gladly add and test the code myself if someone could point me in the right direction.
So lets say you have added a printer and configured it to all the correct settings, like how many input trays, types of output trays, maybe it requires putting in a security pin or it has a punch module. And it looks like this for example.
Then to save those configuration settings you simply need to run this command in a command prompt
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n"Printer Name" /a Path\ConfigFile.dat m f g p
and then to configure the printer once it’s been added with the saved config
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n"Printer Name" /a Path\ConfigFile.dat m f g p
I imagine that the way the print manager works is similar to the script I use to add a printer with the similar command line inputs.
For example, I can use the following script (manually adding in the parameters in the call of installPrinter in the main function) to install a printer. I could probably easily change it to take arguments into the execution like snapin arguments taken from the printer information. Which I imagine is somewhat how the add a printer works.
@ECHO off
call :main
exit
:main
REM Function to call other functions and run the installation process
call :setVars
call :funcHead "Welcome to the Printer installer!"
REM inputs: 1 - Printer Port Name, 2 - printer ip or hostname 3- driverPath 4 - printer name 5 - printer model 6 - config file 7 - raw or lpr
call :installPrinter
EXIT /B
:setVars
REM function for setting script variables, typically for directories
call :funcHead "Setting script variables"
set share="\\networkShare\Printers\Drivers"
net use "%share%"
echo. done!
EXIT /B
:installPrinter
REM Function to add a new Printer
REM inputs: 1 - Printer Port Name, 2 - printer ip or hostname 3- driverPath 4 - printer name 5 - printer model 6 - config file 7 - raw or lpr
call :funcHead "Installing Printer %~4"
call :printerPort %~1 %~2 %~7
call :printerDriver "%~3"
call :addPrinter "%~4" "%~5" %~1
call :configPrinter "%~6" "%~4"
echo. done installing printer %~4!
EXIT /B
:printerPort
REM function for adding a printer port
REM var inputs 1 - port name 2 -hostname or ip address 3 -port type (raw or lpr)
call :dots
echo. Creating the printer port...
IF %~3==lpr (
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r %~1 -h %~2 -o lpr -q lp -n 515
) ELSE ( REM raw
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r %~1 -h %~2 -o raw -n 9100
)
echo. done!
call :dots
EXIT /B
:printerDriver
REM function to add the driver input 1=full driver path
call :dots
echo. Adding printer driver...
PNPUTIL -i -a "%~1"
echo. done!
call :dots
EXIT /B
:addPrinter
REM add the printer to the created port
REM 1 - printer name 2 - printer model associated with driver 3 - port name
call :dots
echo. adding printer to network port...
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs -a -p "%~1" -m "%~2" -r %~3
echo. done!
call :dots
:configPrinter
REM add any special printer configurations
REM 1 - config file path 2 - printer name
call :dots
echo. Configuring Printer...
REM To create a config file for a printer, use the following syntax
REM RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /nPrinterName /a ConfigFilePath.dat m f g p
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n"%~2" /a %~1 m f g p
echo. done!
call :dots
EXIT /B
:dots
REM just echoing dots in a Function instead of copy pasting them so that it's consistent
echo ......................................................................
EXIT /B
:funcHead
REM A simple function for displaying a consistent header at the start of functions
call :dots
echo. %~1
call :dots
EXIT /B
I would rather use the fog print management with the added ability to import printer config files, as it is the only thing it doesn’t do that my scripting method does. Granted I could just set this idea up as a snapin, but I don’t have the remove printer functionality in my script as is. So What can I do to add this functionality in.