zoukankan      html  css  js  c++  java
  • win10x64 批处理自动安装打印机

    系统版本:Windows 10企业版 64位(10.0 ,版本17134)- 中文(简体)

    话不多说,直接上脚本:

    REM 提升管理员权限
    @echo off
    chcp 65001 >nul
    setlocal enabledelayedexpansion
    >nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
    if '%errorlevel%' NEQ '0' (
        goto UACPrompt 
    ) else (
        goto gotAdmin 
    )
    :UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"
    "%temp%getadmin.vbs"
    exit /B
    :gotAdmin
    if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
    pushd "%CD%"
    cd /D "%~dp0"
    
    rem auto install
    @echo off
    chcp 65001 >nul
    title 柯美C226打印机自动安装程序
    color 0a :printer ping 192.168.1.100 -n 1 | findstr /i "TTL" >NUL 2>NUL && goto fileserver echo Cannot connect to the printer ... goto end :fileserver echo Detected the printer is online ... ping 192.168.1.200 -n 1 | findstr /i "TTL" >NUL 2>NUL && goto driver echo Cannot find any drivers of the printer ... goto end :driver

    rem 文件服务器共享目录,存放打印机驱动文件
    net use \192.168.1.200fileserver /delete >nul net use \192.168.1.200fileserver password /user:username >nul if errorlevel 0 goto start echo Connect to the fileserver failed ... goto end :start echo Driver found ... rundll32 printui.dll,PrintUIEntry /dl /n "KONICA MINOLTA C266SeriesPS" /q echo 正在准备安装打印机,请耐心等待 ... rem add port reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPorts" /v StatusUpdateInterval /t REG_DWORD /d 0x0000000a /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPorts" /v StatusUpdateEnabled /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Protocol /t REG_DWORD /d 0x00000002 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Version /t REG_DWORD /d 0x00000002 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v HostName /t REG_SZ /d "192.168.1.100" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v HWAddress /t REG_SZ /d "" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v IPAddress /t REG_SZ /d "" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v PortNumber /t REG_DWORD /d 0x00000203 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Community" /t REG_SZ /d "public" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Enabled" /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Index" /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v PortMonMibPortIndex /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Queue /t REG_SZ /d "print" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "Double Spool" /t REG_DWORD /d 0x00000000 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPorts" /v StatusUpdateInterval /t REG_DWORD /d 0x0000000a /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPorts" /v StatusUpdateEnabled /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Protocol /t REG_DWORD /d 0x00000002 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Version /t REG_DWORD /d 0x00000002 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v HostName /t REG_SZ /d "192.168.1.100" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v HWAddress /t REG_SZ /d "" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v IPAddress /t REG_SZ /d "" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v PortNumber /t REG_DWORD /d 0x00000203 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Community" /t REG_SZ /d "public" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Enabled" /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "SNMP Index" /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v PortMonMibPortIndex /t REG_DWORD /d 0x00000001 /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v Queue /t REG_SZ /d "print" /f >nul reg add "HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.1.100" /v "Double Spool" /t REG_DWORD /d 0x00000000 /f >nul @ping 127.0.0.1 -n 2 >nul rem restart printer service sc stop spooler && sc start spooler @echo off for /f "skip=3 tokens=4" %%i in ('sc query spooler') do set "zt=%%i" && goto :next :next if /i "%zt%"=="RUNNING" ( echo. echo. echo 打印机服务运行正常,打印机安装中 。。。 ) else ( echo 打印机服务处于停止状态。 goto :end ) rem 安装打印机 rundll32 printui.dll,PrintUIEntry /if /b "KONICA MINOLTA C266SeriesPS" /f "\fileserversoftware打印机驱动柯美226_WindowsWin_x64KOAXLA__.INF" /r "IP_192.168.1.100" /m "KONICA MINOLTA C266SeriesPS" /z if not errorlevel 0 goto :end @ping 127.0.0.1 -n 6 >nul echo. echo 打印机已安装成功!!! echo. rem public setting reg add "HKEY_CURRENT_USERSoftwareKONICA MINOLTAKONICA MINOLTA C266SeriesPSKONICA MINOLTA C266SeriesPSAuthentication" /v AuthType /t REG_DWORD /d 0x00000003 /f >nul reg add "HKEY_CURRENT_USERSoftwareKONICA MINOLTAKONICA MINOLTA C266SeriesPSKONICA MINOLTA C266SeriesPSAuthentication" /v UserType /t REG_DWORD /d 0x00000000 /f >nul reg add "HKEY_CURRENT_USERSoftwareKONICA MINOLTAKONICA MINOLTA C266SeriesPSKONICA MINOLTA C266SeriesPSAuthentication" /v UserName /t REG_SZ /d "" /f >nul reg add "HKEY_CURRENT_USERSoftwareKONICA MINOLTAKONICA MINOLTA C266SeriesPSKONICA MINOLTA C266SeriesPSAuthentication" /v UserPass /t REG_BINARY /d "" /f >nul rem 将这个打印机设置为默认打印机 rundll32 printui.dll,PrintUIEntry /y /n "KONICA MINOLTA C266SeriesPS" :end echo. echo. echo Press any key to quit. pause >nul exit
    *** 你必须十分努力,才能看起来毫不费力 ***
  • 相关阅读:
    运用《深入理解Java虚拟机》书中知识解决实际问题
    FPGA实现移动目标检测
    FPGA实现人脸检测
    FPGA实现图像的边缘检测:灰度形态学梯度
    FPGA实现图像的二值形态学滤波:边界提取
    VAST3.0规范
    Flash Socket通信的安全策略问题 843端口
    100个开源游戏
    游戏指标分析
    网络广告类型有哪些?
  • 原文地址:https://www.cnblogs.com/bigtree2pingping/p/10774172.html
Copyright © 2011-2022 走看看