无涯教程-批处理 - Reading from the Registry函数

117 阅读1分钟

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

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

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

@echo off R
EG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\

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

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

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\

注册表中的此位置具有有关Windows系统的一些关键信息,如"System Directory location".

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	

参考链接

www.learnfk.com/batch-scrip…