- Batch Script Tutorial
- Batch Script - Home
- Batch Script - Overview
- Batch Script - Environment
- Batch Script - Commands
- Batch Script - Files
- Batch Script - Syntax
- Batch Script - Variables
- Batch Script - Comments
- Batch Script - Strings
- Batch Script - Arrays
- Batch Script - Decision Making
- Batch Script - Operators
- Batch Script - DATE & TIME
- Batch Script - Input / Output
- Batch Script - Return Code
- Batch Script - Functions
- Batch Script - Process
- Batch Script - Aliases
- Batch Script - Devices
- Batch Script - Registry
- Batch Script - Network
- Batch Script - Printing
- Batch Script - Debugging
- Batch Script - Logging
- Batch Script Resources
- Batch Script - Quick Guide
- Batch Script - Useful Resources
- Batch Script - Discussion
Batch Script - Reading from the Registry
Reading from the registry is done via the REG QUERY command. This command can be used to retrieve values of any key from within the registry.
Syntax
REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value
Where RegKey is the key which needs to be searched for in the registry.
Example
@echo off REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\
The above command will query all the keys and their respective values under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\
Output
The output will display all the keys and values under the registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\
This location in the registry has some key information about the windows system such as the 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
batch_script_registry.htm
Advertisements