继上次做过批处理脚本删除打印机后,上周在思考如何通过批处理脚本添加打印机,折腾了一番现有打印机配置为dat格式后,导出并导入,发现并不能用,再google一番,发现微软有了一套vbs脚本就是干这个事的,存放位置就在 “%WINDIR%\System32\Printing_Admin_Scripts\zh-CN\” 这里,参考来源如下
https://community.spiceworks.com/how_to/71708-how-to-install-printer-driver-and-add-a-network-printer-from-the-command-line
简单来说,就是说分3段来处理添加打印机的过程,1,配置打印机驱动,2,配置打印机端口,3,添加打印机
中午进行了测试,一条条添加几台打印机,发现效果不错,感觉上比一步步添加打印机要快不少,至少省事多了,效果过程图如下:
实际代码如下,供参考:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
@echo off ::============================================================================================================================ :: 设置脚本的标题;颜色 [Background][Text] in hex (0 to F) title 按需添加各楼层多余打印机 "wanjie" [2019-09-03] color FC :MENU ECHO. ECHO.=-=-=-=-=添加各楼层打印机 Powered by Wanjie=-=-=-=-= ECHO. ECHO 1:添加39楼打印机 ECHO 2:添加41楼打印机 ECHO 3:添加42楼打印机 ECHO 4:添加43楼打印机 ECHO 5:查看现有打印机 ECHO 6:退出 ECHO. ECHO. ECHO. echo. 请输入选择楼层的序号后回车: set /p M=Type 1, 2, 3, 4, 5 or 6 then press ENTER: IF %M%==1 GOTO Add39 IF %M%==2 goto Add41 IF %M%==3 goto Add42 IF %M%==4 goto Add43 IF %M%==5 goto ListPrint IF "%M%"=="6"exit PAUSE :Add39 color 08 echo. 执行命令1-添加39楼夏普--SHARP MX5608@F39 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.7.4 -h 10.17.7.4 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "SHARP MX-M5608N PCL6" -h "\\10.17.36.6\打印机驱动\SHARP-5608\sharp_pcl6_ss0e_1606\x64" -i "\\10.17.36.6\打印机驱动\SHARP-5608\sharp_pcl6_ss0e_1606\x64\ss0emchs.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "SHARP MX5608@F39" -m "SHARP MX-M5608N PCL6" -r "IP_10.17.7.4" echo; 39楼夏普打印机添加完毕,请试用,记得设置用户密码:) goto MENU :Add41 color 09 echo 执行命令2-添加41楼打印机--SHARP MX-M503N@F41 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.7.5 -h 10.17.7.5 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "SHARP MX-M503N PCL6" -h "\\10.17.36.6\打印机驱动\夏普 MX-M503N\printer-win10\printer\MX-Mono3_PCL_PS_1302a_ChineseS_Win8Server2012\Chinese1\PCL6\64bit" -i "\\10.17.36.6\打印机驱动\夏普 MX-M503N\printer-win10\printer\MX-Mono3_PCL_PS_1302a_ChineseS_Win8Server2012\Chinese1\PCL6\64bit\sr0emchs.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "SHARP MX-M503N@F41" -m "SHARP MX-M503N PCL6" -r "IP_10.17.7.5" echo; 41楼夏普打印机添加完毕,请试用,记得设置用户密码:) GOTO MENU :Add42 color 0A echo. 执行命令3-添加42楼夏普--SHARP MX-M5608N@F42 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.7.2 -h 10.17.7.2 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "SHARP MX-M5608N PCL6" -h "\\10.17.36.6\打印机驱动\SHARP-5608\sharp_pcl6_ss0e_1606\x64" -i "\\10.17.36.6\打印机驱动\SHARP-5608\sharp_pcl6_ss0e_1606\x64\ss0emchs.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "SHARP MX-M5608N@F42" -m "SHARP MX-M5608N PCL6" -r "IP_10.17.7.2" echo; 39楼夏普打印机添加完毕,请试用,记得设置用户密码:) echo. 执行命令3-添加42楼佳能--Canon LBP6650@F42茶水间左 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.34.198 -h 10.17.34.198 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "Canon LBP6670 UFR II" -h "\\10.17.36.6\打印机驱动\6670\win64\Driver" -i "\\10.17.36.6\打印机驱动\6670\win64\Driver\CNLB0CA64.INF" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "Canon LBP6650@F42茶水间左" -m "Canon LBP6670 UFR II" -r "IP_10.17.34.198" echo; 42楼佳能--Canon LBP6650@F42茶水间左打印机添加完毕,请试用 echo. 执行命令3-添加42楼佳能--Canon LBP6650@F42楼茶水间中 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.39.127 -h 10.17.39.127 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "Canon LBP6650/3470 UFR II" -h "\\10.17.36.6\打印机驱动\6670\win64\Driver" -i "\\10.17.36.6\打印机驱动\6670\win64\Driver\CNLB0CA64.INF" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "Canon LBP6650@F42楼茶水间中" -m "Canon LBP6670 UFR II" -r "IP_10.17.39.127" echo; Canon LBP6650@F42楼茶水间中-打印机添加完毕,请试用:) GOTO MENU :Add43 color 09 echo 执行命令4-添加43楼夏普打印机--SHARP MX-M503N@F43 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.7.3 -h 10.17.7.3 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "SHARP MX-M503N PCL6" -h "\\10.17.36.6\打印机驱动\夏普 MX-M503N\printer-win10\printer\MX-Mono3_PCL_PS_1302a_ChineseS_Win8Server2012\Chinese1\PCL6\64bit" -i "\\10.17.36.6\打印机驱动\夏普 MX-M503N\printer-win10\printer\MX-Mono3_PCL_PS_1302a_ChineseS_Win8Server2012\Chinese1\PCL6\64bit\sr0emchs.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "SHARP MX-M503N@F43" -m "SHARP MX-M503N PCL6" -r "IP_10.17.7.3" echo; 43楼夏普打印机添加完毕,请试用,记得设置用户密码:) echo 执行命令4-添加43楼惠普--HP577彩色@老师边上 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.33.205 -h 10.17.33.205 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "HP Universal Printing PCL 6" -h "\\10.17.36.6\打印机驱动\HP577" -i "\\10.17.36.6\打印机驱动\HP577\hpcu220u.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "HP577彩色@老师边上" -m "HP Universal Printing PCL 6" -r "IP_10.17.33.205" echo; HP577彩色@老师边上添加完毕,请试用:) echo 执行命令4-添加43楼惠普--HP577彩色@Room4320 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.34.203 -h 10.17.34.203 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "HP Universal Printing PCL 6" -h "\\10.17.36.6\打印机驱动\HP577" -i "\\10.17.36.6\打印机驱动\HP577\hpcu220u.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "HP577彩色@Room4320" -m "HP Universal Printing PCL 6" -r "IP_10.17.34.203" echo; HP577彩色@Room4320添加完毕,请试用:) echo 执行命令4-添加43楼惠普--HP4525彩色@F43前台后面房间 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.33.236 -h 10.17.33.236 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "HP Color LaserJet CP4520 Series PCL6" -h "\\10.17.36.6\打印机驱动\前台彩色打印机HP_CP4525_drv" -i "\\10.17.36.6\打印机驱动\前台彩色打印机HP_CP4525_drv\hpc4520u.inf" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "HP4525彩色@F43前台后面房间" -m "HP Color LaserJet CP4520 Series PCL6" -r "IP_10.17.33.236" echo; -HP4525彩色@F43前台后面房间添加完毕,请试用:) echo. 执行命令4-添加43楼佳能--Canon LBP6670黑白@Room4320 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnport.vbs -a -r IP_10.17.34.210 -h 10.17.34.210 Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prndrvr.vbs -a -m "Canon LBP6670 UFR II" -h "\\10.17.36.6\打印机驱动\6670\win64\Driver" -i "\\10.17.36.6\打印机驱动\6670\win64\Driver\CNLB0CA64.INF" Cscript %WINDIR%\System32\Printing_Admin_Scripts\zh-CN\Prnmngr.vbs -a -p "Canon LBP6670黑白@Room4320" -m "Canon LBP6670 UFR II" -r "IP_10.17.34.210" echo; 43楼佳能--Canon LBP6670黑白@Room4320打印机添加完毕,请试用 GOTO MENU :ListPrint color 0C wmic printer get Name /value :cmd6 echo 执行命令6-退出菜单 GOTO MENU |
文章评论