Skip to content

Instantly share code, notes, and snippets.

@Techlogist
Last active October 3, 2021 12:34
Show Gist options
  • Save Techlogist/db4c41f7c9c88ee0407ca53e151f0972 to your computer and use it in GitHub Desktop.
Save Techlogist/db4c41f7c9c88ee0407ca53e151f0972 to your computer and use it in GitHub Desktop.
How to map a network printer with an IP using Command Line ?
REM License: GNU General Public License v2.0
REM Author: Miguel
REM Website: www.techlogist.net
REM Post: https://techlogist.net/batch/how-to-map-a-network-printer-with-an-ip-using-command-line
REM Description: Map a network printer with an IP using Command Line
REM OS/Language/Region: Windows/EN-US
REM Set IP of the printer
set IP=192.168.8.24
REM The printer name can be any you want but without spaces
set Printer_Name=Printer-at-Office
REM The driver name must the one found inside the INF file
set Driver_Name=Driver Name
REM The location of the printer driver .INF file (it can be a remote share)
set INF=\\192.168.8.10\folder\driver_folder\file_x64.inf
REM Finds the correct path for "Printing_Admin_Scripts" (because they change according OS to the language)
set Return_path=%cd%
for /d %%i in (C:\Windows\System32\Printing_Admin_Scripts\*) do cd %%i
set path_folder=%cd%
cd %return_path%
REM The script
rundll32 printui.dll,PrintUIEntry /dl /n "%Printer_Name%" /q
cscript %path_folder%\prnport.vbs -a -r IP%IP% -h %IP% -n 9100 -o raw -me
rundll32 printui.dll,PrintUIEntry /ia /m "%Driver_Name%" /f "%inf%"
rundll32 printui.dll,PrintUIEntry /if /m "%Driver_Name%" /b "%Printer_Name%" /f "%inf%" /r IP%IP%
:EOF
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment