3. Working with System Management Tools
System Management is one of those catch-all terms
that encompasses a range of tasks, from simple adjustments such as
changing the system date and time to more complex tweaks such as
modifying the Registry. Windows Home Server’s command-line system
management tools also enable you to monitor system performance, shut
down or restart the computer, and even modify the huge Windows
Management Instrumentation (WMI) interface. Table 4 lists the system management command-line tools that apply to Windows Home Server.
Table 4. Windows Home Server’s Command-Line System Management Tools
Tool | Description |
---|
CHCP | Displays or changes the number of active console code pages. |
DATE | Displays or sets the system date. |
EVENTCREATE | Creates a custom event in an event log. |
REG | Adds, modifies, displays, and deletes Registry keys and settings. |
REGSVR32 | Registers dynamic-link library (DLL) files as command components in the Registry. |
SHUTDOWN | Shuts down or restarts Windows Home Server or a remote computer. |
SYSTEMINFO | Displays a wide range of detailed configuration information about the computer. |
TIME | Displays or sets the system time. |
TYPEPERF | Monitors a performance counter. |
WHOAMI | Displays
information about the current user, including the domain name (not
applicable to Windows Home Server), computer name, username, security
group membership, and security privileges. |
WMIC | Operates the Windows Management Instrumentation command-line tool that provides command-line access to the WMI interface. |
The next few sections take more detailed looks at five of these command-line tools: REG, SHUTDOWN, SYSTEMINFO, TYPEPERF, and WHOAMI.
REG: Working with Registry Keys and Settings
There may be some settings that you change quite often. In such
cases, it can become burdensome to frequently launch the Registry
Editor and change the settings. A better idea is to create a shortcut or
batch file that uses the REG command-line tool to make your Registry changes for you.
REG actually consists of 11 subcommands, each of which enables you to perform different Registry tasks:
REG ADD | Adds new keys or settings to the Registry. You can also use this command to modify existing settings. |
REG QUERY | Displays the current values of one or more settings in one or more keys. |
REG COMPARE | Compares the values of two Registry keys or settings. |
REG COPY | Copies Registry keys or settings to another part of the Registry. |
REG DELETE | Deletes a key or setting. |
REG EXPORT | Exports a key to a .reg file. |
REG IMPORT | Imports the contents of a .reg file. |
REG SAVE | Copies Registry keys or settings to a hive (.hiv) file. |
REG RESTORE | Writes a hive file into an existing Registry key. The hive file must be created using REG SAVE. |
REG LOAD | Loads a hive file into a new Registry key. The hive file must be created using REG SAVE. |
REG UNLOAD | Unloads a hive file that was loaded using REG LOAD. |
I won’t go through all these commands. Instead, I’ll
focus on the three most common Registry tasks: viewing, adding, and
modifying Registry data.
Viewing Registry Data
To view the current value of the Registry setting, you use the REG QUERY command:
REG QUERY KeyName [/V SettingName | /VE] [/C] [/D] [/E] [/F data] [/K | [/S] [/SE separator] [/T type] [/Z]
KeyName | The Registry key that contains the setting or settings that you want to view. The KeyName must include a root key value: HKCR, HKCU, HKLM, HKU, or HKCC. Place quotation marks around key names that include spaces. |
/V ValueName | The Registry setting in KeyName that you want to view. |
/VE | Tells REG to look for empty settings (that is, settings with a null value). |
/F data | Specifies the data that REG should match in the KeyName settings. |
/C | Runs a case-sensitive query. |
/E | Returns only exact matches. |
/K | Queries only key names, not settings. |
/S | Tells REG to query the subkeys of KeyName. |
/SE separator | Defines the separator to search for in REG_MULTI_SZ settings. |
/T type | Specifies the setting type or types to search: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, or REG_NONE. |
/Z | Tells REG to include the numeric equivalent of the setting type in the query results. |
For example, if you want to know the current value of the RegisteredOwner setting in HKLM\Software\Microsoft\Windows NT\CurrentVersion, you’d run the following command:
reg query "hklm\software\microsoft\windows nt\currentversion" /v registeredowner
The
Registry Editor has a Find command that enables you to look for text
within the Registry. However, it would occasionally be useful to see a
list of the Registry keys and settings that contains a particular bit of
text. You can do this using the /F switch. For example, suppose you want to see a list of all the HKLM keys and settings that contain the text Home Server. Here’s a command that will do this:
reg query hklm /f "Home Server " /s
Adding Registry Data
To add a key or setting to the Registry, use the REG ADD command:
REG ADD KeyName [/V SettingName | /VE] [/D data] [/F | [/S separator] [/T type]
KeyName | The Registry key that you want to add or to which you want to add a setting. The KeyName must include a root key value: HKCR, HKCU, HKLM, HKU, or HKCC. Place quotation marks around key names that include spaces. |
/V ValueName | The setting that you want to add to KeyName. |
/VE | Tells REG to add an empty setting. |
/D data | Specifies the data that REG should use as the value for the new setting. |
/F | Modifies an existing key or setting without prompting to confirm the change. |
/S separator | Defines the separator to use between multiple instances of data in a new REG_MULTI_SZ setting. |
/T type | Specifies the setting type: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, or REG_NONE. |
For example, the following command adds a key named MySettings to the HKCU root key:
Here’s another example that adds a setting named CurrentProject to the new MySettings key and sets the value of the new settings to WHS Unleashed:
reg add hkcu\MySettings /v CurrentProject /d "WHS Unleashed"
Modifying Registry Data
If you want to make changes to an existing setting, run REG ADD on the setting. For example, to change the HKCU\MySettings\CurrentProject setting to Windows Home Server Unleashed, you run the following command:
reg add hkcu\MySettings /v CurrentProject /d "Windows Home Server Unleashed"
Windows Home Server responds with the following prompt:
Value CurrentProject exists, overwrite (Yes/No)?
To change the existing value, press Y and press Enter.
Tip
To avoid being prompted when changing existing settings, add the /F switch to the REG ADD command.