注册表操作CMD(reg.exe)

  在cmd进行注册表进行操作,可以使用Reg命令(reg.exe),可以在 %windir%\system32下找到此文件. 详情参见:http://technet.microsoft.com/en-us/library/cc732643(WS.10).aspx 这个链接可以查询到其他的cmd中命令.

其他关于reg的操作的工具有:RegBack.exe, RegRest.exe, and Regedt32.exe,参见:http://technet.microsoft.com/en-us/library/cc758453(WS.10).aspx

  

下面是reg.exe的介绍:

C:\Users\your_username>reg /?

REG Operation [Parameter List]

  Operation  [ QUERY   | ADD    | DELETE  | COPY    |
               SAVE    | LOAD   | UNLOAD  | RESTORE |
               COMPARE | EXPORT | IMPORT  | FLAGS ]

Return Code: (Except for REG COMPARE)

  0 - Successful
  1 - Failed

For help on a specific operation type:

  REG Operation /?

Examples:

  REG QUERY /?

C:\Users\your_username>reg QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\InstalledProducts

可以应用查询结果到for中:

for /f "usebackq tokens=1,2,3* delims==" %%i in (`reg QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0 /v InstallDir`) do (
    echo  "%%i"
)

  REG ADD /?
  REG DELETE /?
  REG COPY /?
  REG SAVE /?
  REG RESTORE /?
  REG LOAD /?
  REG UNLOAD /?
  REG COMPARE /?
  REG EXPORT /?
  REG IMPORT /?
  REG FLAGS /?

Reference:

http://technet.microsoft.com/en-us/library/cc781440(WS.10).aspx

http://technet.microsoft.com/en-us/library/cc758453(WS.10).aspx

http://www.computerhope.com/reg.htm#04

http://commandwindows.com/reg.htm

原文地址:https://www.cnblogs.com/zzj8704/p/1678965.html