批处理脚本 - 从注册表中读取

从注册表中读取数据是通过 REG QUERY 命令完成的。 此命令可用于从注册表中检索任何键的值。

语法

REG QUERY [ROOT\]RegKey /v ValueName [/s] 
REG QUERY [ROOT\]RegKey /ve --This returns the (default) value

其中RegKey是需要在注册表中搜索的键。

示例

@echo off 
REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\

上述命令将查询注册表项HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\下的所有键及其各自的值

输出

输出将显示注册表项下的所有键和值。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\

注册表中的此位置包含有关 Windows 系统的一些关键信息,例如系统目录位置。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows
   Directory REG_EXPAND_SZ %SystemRoot%
   SystemDirectory REG_EXPAND_SZ %SystemRoot%\system32
   NoInteractiveServices REG_DWORD 0x1
   CSDBuildNumber REG_DWORD 0x4000
   ShellErrorMode REG_DWORD 0x1
   ComponentizedBuild REG_DWORD 0x1
   CSDVersion REG_DWORD 0x0
   ErrorMode REG_DWORD 0x0
   CSDReleaseType REG_DWORD 0x0
   ShutdownTime REG_BINARY 3AFEF5D05D46D101	

❮ batch_script_registry.html