Document Contents

Abstract 1

License. 1

Disclaimer 1

Syntax: 1

Option Summary. 1

Registry Path Names. 4

Command Line Examples: 5

Batch file Examples: 5

Run a command using the value in a registry entry. 5

Get the data type and value into environment variables. 5

 

DTREG.EXE

Version 1.0s

Copyright 1994-2001 by David G. Thomas

Last changed May, 1998

To obtain the latest version, visit http://www.tamedos.com/downloads

 

Note: This application was renamed from REG to DtReg so that it will not conflict with the Microsoft program that is also called Reg.exe.

Abstract

DTREG provides an efficient way to apply batch updates to the Windows NT registry.  It also allows querying the registry.

License

This program may be freely distributed as long as this document file is distributed with it and no money is charged.  If Tame is included with a suite of utilities then the distributor may charge a small distribution fee, but no additional fee may be charged for inclusion of REG.

 

This program is provided free of charge by the author of Tame(r).   Tame improves performance when running DOS applications in a multi-tasking system such as Windows NT and Windows 95.

 

DTREG.EXE is Copyright 1994-2001 by David G. Thomas.  Questions or comments may be addressed to mailto:reg@tamedos.com.

Disclaimer

 

This is a plain-language version of the standard disclaimer.  This program is provided as-is.  I tried to make it useful, functional and bug free, but in reality, the program is not guaranteed to do anything, and if it does something undesirable then the author is not liable.   Use it at your own risk.

Syntax:

DtReg {options}

Option Summary

All options may be abbreviated.  The abbreviated form is indicated with upper case letters.

@option_file

Options will be read from the specified file name.  Lines beginning with a semi-colon (;) will be treated as a comment and ignored.  This is the same as using the –InputFile option with option_file as the path.

-AddKey keyname ...

Add the specified key to the registry.

-CheckKey keyname ...

Check if the key is in the registry, and set the ERRORLEVEL to 1 if it does not exist.

-ComputerName name

Specify the computer that all registry operations will occur on.

-Deletevalue name ...

Remove the named registry value.

-DeleteKey name ...

Remove the named registry key.  Note that the key must be empty before deleting it.

-DeleteTree name ...

Remove the named registry key and all sub-keys that are contained in it

-EnvLoad bat_file

Scan the batch file dor PATH and SET statements, and load the Windows NT user environment with the values that are found.  This may be used in order to permanently load the AUTOEXEC.BAT into the Windows NT environment.

Note that the COMSPEC environment value is always ignored.  This is because COMSPEC can cause lots of grief if it is set to the DOS version of COMMAND.COM.

-EnvPathAdd dir ...

Add the directory to the end of the user path.  If it already is in the path, it will remain unchanged.

Note that this command will not affect any currently open windows.  When a new window is launched from Program Manager, it will reflect the modified value.

-EnvPathDelete dir ...

Remove the directory from the user path.

Note that this command will not affect any currently open windows.  When a new window is launched from Program Manager, it will reflect the modified value.

-EnvSet name=value ...

Set the specified user environment value.

Note that this command will not affect any currently open windows.  When a new window is launched from Program Manager, it will reflect the modified value.

-InputFile filename

Load options from the specified file.  This is the same as @filename.

-ExpandEnvironmentValues buffer_size

Expand environment values that are specified in an option file.  Environment value names should be enclosed in ‘%’ marks, as is done with normal batch files.  The buffer size is an optional argument that sets the maximum length of an expanded string.  The default is 2000 characters if no buffer size is specified.  If a buffer size of 0 is specified then this disables expansion of values.  The default is to not expand values.

-List value

List the specified registry value in the form ‘Name’ = TypeValue’.

-ListValue

List the specified registry value without the name and without quoting the value.  This form of output is more suitable to piping into the Windows NT for command to extract the type and/or value into environment values (See examples below).

-MachineEnvLoad bat_file

Scan the batch file for PATH and SET statements, and load the Windows NT machine environment with the values that are found.  This may be used in order to permanently load the AUTOEXEC.BAT into the Windows NT environment.

Note that the COMSPEC environment value is always ignored.  This is because COMSPEC can cause lots of grief if it is set to the DOS version of COMMAND.COM.

Note also that this command will not affect any currently open windows.  When a new window is launched from Program Manager, it will reflect the modified value.

-MachineEnvPathAdd dir ...

Add the directory to the end of the machine path.  If it already is in the path, it will remain unchanged.

Note that this command will not affect any currently open windows.  When a new window is launched, it will reflect the modified value.

-MachineEnvPathDelete dir ...

Remove the directory from the machine path.

Note that this command will not affect any currently open windows.  When a new window is launched, it will reflect the modified value.

-MachineEnvSet name=value ...

Set the specified machine environment value.

Note that this command will not affect any currently open windows.  When a new window is launched, it will reflect the modified value.

-PATH

Display the current user and machine path as specified in the registry.

-Quiet

Produce no messages unless an error occurs.

-QuerySet name

Set the value based on keyboard response from the user.  This is a very primitive interface, but it does work...

-RestoreKey filename keyname

Load the key values and sub-keys that were previously saved using –SaveKey.

-SaveKey filename keyname

Save the key values and sub-keys that they may later be loaded into the registry using –RestoreKey.

-Set [type] name=value...

Set the specified registry variable to the specified value.  The following types of values are accepted:

REG_DWORD            Integer value that may be in decimal, or hex by specifying 0x as a prefix.

REG_SZ                       Simple string value

REG_EXPAND_SZ    A value that contains %environment% references that may be expanded

REG_MULTI_SZ        A multi-line string where the first character of the value is a line delimiter.

-ValueDeLiMiter character

Set the delimiter that separates the registry key name from the value name.  This may be used when the name of a value must contain a backslash.   Note that key names may not contain a backslash, but it is allowed with value names.

Registry Path Names

 

Notes:

1.        If the path (or any other argument) contains spaces, it should be enclosed in quotes (“)

2.        If a value name is blank, enclose the path name in quotes and specify a trailing blank (e.g. “\path\ “)

Path components

 

\root\item\name

Absolute registry path name where the root may be User, Users or Machine.  User refers to HKEY_CURRENT_USER, Users refers to HKEY_USERS and Machine refers to HKEY_LOCAL_MACHINE,

This may also be the 4 letter common acronym for the root key name. HKCU, HKU, HKLM, HKCR, HKCC or HKDD are currently accepted values.

\path\

A trailing back slash sets the default key that subsequent names are in

Key\name

A specification relative to the default key

\\machine\root\name

Registry path may be specified on a different machine

 

The following root names are valid.

 

HKCC

HKEY_CURRENT_CONFIG

HKCR

HKEY_CLASSES_ROOT

HKCU

HKEY_CURRENT_USER

HKDD

HKEY_DYN_DATA

HKU

HKEY_USERS

HKLM

HKEY_LOCAL_MACHINE

 

Command Line Examples:

REG @SETUSER.RI

Load options that are listed in file SETUSER.RI. 

REG -AddKey \User\Software\Test

Add the key

REG -Set  \User\Software\Test\Value=“Test Value”

Set the value of  \User\Software\Test\Value to a REG_SZ value of “Test Value”

REG -Set REG_DWORD \User\Software\Test\ value1=10 value2=20

This will set two values that are of type REG_DWORD and are in the \User\Software\Test key.

REG -Set \\SERVER01\Machine\Software\Test\Value = C:\

This will set a registry value on a remote machine. 

REG -Set “\\SERVER01\Machine\Software\Test\ “ = DefaultValue

This will set the default registry value for the Test key.  Note the space after the last backslash in the path specification.

REG –SET –ValueDelimiter “$” -Set \HKCU\Software\Paths$C:\TEST.LOG = Log

This will set a value named “C:\TEST.LOG”

Batch file Examples:

Run a command using the value in a registry entry

The following batch file uses the extended syntax of the “for” command to extract the value and use it in the batch file. It has been tested with Windows NT version 4.0.

@echo off
rem This batch file will list the directory of the Windows NT source CD
set rp="\machine\software\Microsoft\Windows NT\CurrentVersion\SourcePath"
for /f "tokens=1*" %%i in ('reg -lv %rp%') do dir %%j

Get the data type and value into environment variables

The following batch file uses the extended syntax of the for command to extract the data type and value into environment values that may be used in the batch file. It has been tested with Windows NT version 4.0.

   @echo off
   rem This batch file will list the directory of the Windows NT source CD
   set rp="\machine\software\Microsoft\Windows NT\CurrentVersion\SourcePath"
   for /f "tokens=1*" %%i in ('reg -lv %rp%') do set RegValueType=%%i&set RegValue=%%j
   if %RegValueType% == Undefined goto error

   echo dir %RegValue%

   dir %RegValue%
   goto done

:error
   echo **** %RegValueType% %RegValue%

:done
   set rp=
   set RegValue=
   set RegValueType=