@ECHO OFF
chcp 65001
setlocal EnableDelayedExpansion
color 3e
title 柯美c266打印机安装
PUSHD %~DP0 & cd /d "%~dp0"
%1 %2
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :runas","","runas",1)(window.close)&goto :eof
:runas
::填写自己的脚本set desk =""
For /f "tokens=3,*" %%i in ('reg query "hkcu\software\microsoft\windows\currentversion\explorer\shell folders" /v "desktop"') do (set desk=%%i)
echo 请输入共享打印机名称(自带检查重复打印机有重复打印机自动先删除再安装,带空格的名称请填写“打印名称”)
set /P a=""
echo 请输入打印机的(USB001 USB001代表usb1 网络打印机请先运行reg 添加好IP端口号)
set /p b=""
:add_port
echo.
echo. 正在添加打印机端口
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "Protocol" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "Version" /t REG_DWORD /d 0x2 /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "HostName" /t REG_SZ /d "%b%" /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "IPAddress" /t REG_SZ /d "" /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "HWAddress" /t REG_SZ /d "" /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "PortNumber" /t REG_DWORD /d 0x238c /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Community" /t REG_SZ /d "public" /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Enabled" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Index" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "PortMonMibPortIndex" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "Protocol" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "Version" /t REG_DWORD /d 0x2 /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "HostName" /t REG_SZ /d "%b%" /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "IPAddress" /t REG_SZ /d "" /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "HWAddress" /t REG_SZ /d "" /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "PortNumber" /t REG_DWORD /d 0x238c /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Community" /t REG_SZ /d "public" /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Enabled" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "SNMP Index" /t REG_DWORD /d 0x1 /f>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\%b%" /v "PortMonMibPortIndex" /t REG_DWORD /d 0x1 /f>nul
echo.
echo. 正在重启打印服务,请稍等……
echo.
rem 必须重启打印服务才能成功添加端口
net stop spooler>nul
net start spooler>nul
if errorlevel 0 echo. 打印服务重启成功
echo. ..............................................
::lpt1
rundll32 printui.dll,PrintUIEntry /dl /n %a% /q
echo %ERRORLEVEL%
rundll32 printui.dll,PrintUIEntry /if /Z /b %a% /f %desk%\BHC266PCL6Winx64_7300ZH-CN\KOAXLJ__.inf /r "%b%" /m "KONICA MINOLTA C266SeriesPCL"
echo %ERRORLEVEL%
for /f "delims=: tokens=2" %%i in ('ipconfig ^| find "IPv4" 2^>nul') do (
set ipaddr=%%i
set ipaddr=!ipaddr: =!
@echo !ipaddr!/%a%rd /s/q %userprofile%\Desktop\\BHC266PCL6Winx64_7300ZH-CN
echo %ERRORLEVEL%
del /q %userprofile%\Desktop\c266.cmd
echo %ERRORLEVEL%
echo 执行完毕,任意键退出
pause >nul
del /f /q %desk%\c266.exe
exit
)
思路 reg 添加IP端口地址借鉴 再去添加打印机即可