Board logo

标题: [文本处理] 怎么把注册表写到批处理里? [打印本页]

作者: xiang1771    时间: 2018-9-20 09:17     标题: 怎么把注册表写到批处理里?

注册表里,直接加reg add吗?不是很明白……。
我想把下面两个脚本合并成一个。
  1. @echo off
  2. color 0A
  3. echo.
  4. echo.
  5. echo.
  6. rem 自动判断电脑是32位还是64位
  7. if /i "%PROCESSOR_IDENTIFIER:~0,3%"=="X86" (goto 32bit) ELSE (goto 64bit)
  8. :64bit
  9. echo 正在为您安装64位打印机驱动
  10. echo.
  11. rem 导入添加端口的注册表文件
  12. reg import 17wysh.reg    ####应该是把注册表加到这吧?但我不知道用什么命令~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. if errorlevel 0 echo 网络打印机端口安装成功
  14. echo.
  15. echo 正在重启打印服务,请稍等……
  16. echo.
  17. rem 必须重启打印服务才能成功添加端口
  18. net stop spooler>nul
  19. net start spooler>nul
  20. if errorlevel 0 echo 打印服务重启成功
  21. echo ..............................................
  22. echo ..............................................
  23. echo 删除已经存在的同名打印机
  24. rundll32 printui.dll,PrintUIEntry /dl /n "HP LaserJet MFP M725 PCL 6" /q
  25. echo.
  26. echo 安装HP LaserJet MFP M725 PCL 6打印机......
  27. echo.
  28. rundll32 printui.dll,PrintUIEntry /if /b "HP LaserJet MFP M725 PCL 6(17层文印室)" /f \\11.150.191.219\02常用驱动\1HP打印驱动\laserjet_m725\x64\hpcm725u.inf /r "IP_11.150.169.117" /m "HP LaserJet MFP M725 PCL 6" /z
  29. if errorlevel 0 echo 打印机安装成功
  30. echo.
  31. rem 安装好打印机后,也可以在批处理文件最后加一行命令,把这个打印机设置为默认。
  32. echo.
  33. echo 将这个打印机设置为默认打印机
  34. rundll32 printui.dll,PrintUIEntry /y /n "HP LaserJet MFP M725 PCL 6(17层文印室)"
  35. goto end
  36. :32bit
  37. echo 正在为您安装32位打印机驱动
  38. echo.
  39. reg import 17wysh.reg   ####应该是把注册表加到这吧?但我不知道用什么命令~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. if errorlevel 0 echo 网络打印机端口安装成功
  41. echo.
  42. echo 正在重启打印服务,请稍等……
  43. echo.
  44. net stop spooler>nul
  45. net start spooler>nul
  46. if errorlevel 0 echo 打印服务重启成功
  47. echo ..............................................
  48. echo ..............................................
  49. echo 删除已经存在的同名打印机
  50. rundll32 printui.dll,PrintUIEntry /dl /n "HP LaserJet MFP M725 PCL 6" /q
  51. echo.
  52. echo 安装HP LaserJet MFP M725 PCL 6......
  53. echo.
  54. rundll32 printui.dll,PrintUIEntry /if /b "HP LaserJet MFP M725 PCL 6(17层文印室)" /f \\11.150.191.219\02常用驱动\1HP打印驱动\laserjet_m725\x86\hpcm725c.inf /r "IP_11.150.169.117" /m "HP LaserJet MFP M725 PCL 6" /z
  55. if errorlevel 0 echo 打印机安装成功
  56. echo.
  57. echo.
  58. echo 将这个打印机设置为默认打印机
  59. rundll32 printui.dll,PrintUIEntry /y /n "HP LaserJet MFP M725 PCL 6(17层文印室)"
  60. :end
  61. echo 请按任意键退出
  62. pause>nul
复制代码
如何把这个注册表转换成BAT……
  1. Windows Registry Editor Version 5.00
  2. [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports]
  3. "StatusUpdateInterval"=dword:0000000a
  4. "StatusUpdateEnabled"=dword:00000001
  5. [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117]
  6. "Protocol"=dword:00000002
  7. "Version"=dword:00000002
  8. "HostName"="11.150.169.117"
  9. "IPAddress"=""
  10. "HWAddress"=""
  11. "PortNumber"=dword:00000203
  12. "SNMP Community"="public"
  13. "SNMP Enabled"=dword:00000001
  14. "SNMP Index"=dword:00000001
  15. "PortMonMibPortIndex"=dword:00000001
  16. "Queue"="print"
  17. "Double Spool"=dword:00000000
  18. [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports]
  19. "StatusUpdateInterval"=dword:0000000a
  20. "StatusUpdateEnabled"=dword:00000001
  21. [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117]
  22. "Protocol"=dword:00000002
  23. "Version"=dword:00000002
  24. "HostName"="11.150.169.117"
  25. "IPAddress"=""
  26. "HWAddress"=""
  27. "PortNumber"=dword:00000203
  28. "SNMP Community"="public"
  29. "SNMP Enabled"=dword:00000001
  30. "SNMP Index"=dword:00000001
  31. "PortMonMibPortIndex"=dword:00000001
  32. "Queue"="print"
  33. "Double Spool"=dword:00000000
复制代码

作者: 窄口牛    时间: 2018-9-20 09:39

[code@echo off
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports" /v "StatusUpdateInterval" /t REG_DWORD /d 10 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports" /v "StatusUpdateEnabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Protocol" /t REG_DWORD /d 2 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Version" /t REG_DWORD /d 2 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "HostName" /d "11.150.169.117" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "IPAddress" /d "" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "HWAddress" /d "" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "PortNumber" /t REG_DWORD /d 515 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Community" /d "public" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Enabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Index" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "PortMonMibPortIndex" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Queue" /d "print" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Double Spool" /t REG_DWORD /d 0 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports" /v "StatusUpdateInterval" /t REG_DWORD /d 10 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports" /v "StatusUpdateEnabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Protocol" /t REG_DWORD /d 2 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Version" /t REG_DWORD /d 2 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "HostName" /d "11.150.169.117" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "IPAddress" /d "" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "HWAddress" /d "" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "PortNumber" /t REG_DWORD /d 515 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Community" /d "public" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Enabled" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "SNMP Index" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "PortMonMibPortIndex" /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Queue" /d "print" /f
reg add "HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_11.150.169.117" /v "Double Spool" /t REG_DWORD /d 0 /f
][/code]
作者: Batcher    时间: 2018-9-20 11:06

看看 reg add 命令教程和例子,很简单的:
http://bbs.bathome.net/thread-3747-1-1.html




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2