talama

Script to auto install a local printer using tcp/ip

May 7th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.48 KB | None | 0 0
  1. @ECHO OFF
  2.  
  3. REM creating folders on the remote machine to copy the drivers and printer scripts you'll need to install the printer
  4. REM I chose two folders to keep my drivers and scripts separate to keep it simple, you can use one folder if you REM: wish
  5.  
  6. md C:\DRIVERS
  7. md C:\SCRIPTS
  8.  
  9. REM Using xcopy to grab the "2kXPVista" file off of the server which contains the .inf and .dll files for the Sharp MX-M623N printer.
  10. REM Most sharp printers have this "2kXPVista" file buried in their driver when you download it from
  11. REM For this particular Sharp MX-M623N printer, our .inf file is "sr0ejenu.inf"
  12. REM If you look in the .inf file for your driver you’ll see the model you need, in our case it’s "SHARP MX-M623N REM: PCL6"
  13.  
  14. xcopy "\\SERVER\DRIVER_FOLDER\Sharp\MX-M623N\BF2SP-PCL6PS-1104a-2kxpVista-WHQL\EnglishA\PCL6\2kXPVista" C:\DRIVERS /I /y /D
  15.  
  16. REM /I If destination does not exist and copying more than one file, assumes that destination must be a directory.
  17. REM /Y Suppresses prompting to confirm that you want to overwrite an existing destination file.
  18. REM /D if you want the file or files to be copied to a directory
  19.  
  20. REM Win7 built in printer scripts
  21. REM cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prndrvr.vbs (adds printer drivers)
  22. REM Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs (adds printer port)
  23. REM Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs (ties the name, port, and driver together)
  24.  
  25. REM I have these three scripts I copy from a server which also work on XP, Vista, and Win7
  26.  
  27. xcopy "\\SERVER\FOLDER\Scripts" C:\Scripts /I /Y /D
  28.  
  29. REM The first Prnmngr.vbs is to delete the printer if you're trying to add a printer with the same name
  30. cscript "C:\Scripts\Prnmngr.vbs" -d -p "PHS - Online"
  31.  
  32. REM Adds a printer port with name "IP_PRINTERIP" and IP address of "PRINTERIP"
  33. Cscript "C:\Scripts\Prnport.vbs" -a -r IP_PRINTERIP -h PRINTERIP -o raw -n 9100
  34.  
  35. REM Installs the printer driver, first getting the printer model and .inf file, then -h for the path to the .dll
  36. Cscript "C:\Scripts\Prndrvr.vbs" -a -m "SHARP MX-M623N PCL6" -i C:\DRIVERS\sr0ejenu.inf -h C:\DRIVERS
  37.  
  38. REM Finally giving the printer a name of "PHS - Online", linking the model and printer port
  39. Cscript "C:\Scripts\Prnmngr.vbs" -a -p "PHS - Online" -m "SHARP MX-M623N PCL6" -r IP_PRINTERIP
  40.  
  41. REM Last, deleting the directories
  42. rd C:\SCRIPTS /s /q
  43. rd C:\DRIVERS /s /q
  44.  
  45. REM I add the pause in just in case it errors, I will be able to see what it is
  46. @pause
Advertisement
Add Comment
Please, Sign In to add comment