Because the Registry Editor is actually a bi-type program that can be run on DOS or Windows 95/98. Many users may already know how to use Regedit on Windows. Therefore, to master the programming of the registry under DOS, you must first understand how to use the registry editor under DOS.
Type the Regedit command at the DOS prompt and a help screen will appear. This screen gives its command line parameters and how to use it.
Syntax: Regedit [/L:system] [/R:user] filename1
Regedit [/L:system] [/R:user] /C filename2
Regedit [/L:system] [/R:user] /E filename3 [regpath]
in:
/L:system Specifies the storage location of the file.
/L:user Specifies the storage location of the file.
filename1 Specifies the file name to introduce the registry database.
/C filename2 Specifies the file name that forms the registry database.
/E filename3 Specifies the file name for exporting the registry file.
regpath specifies the start keyword for exporting the registry file (default is all keywords)
Let me give you a few examples to illustrate how to use it in DOS.
[Example 1] Export the system registry database registry to a file.
regedit /E
[Example 2] Form the system registry database registry (all).
regedit /C
[Example 3] It will be introduced into the system registry database (partial).
regedit
[Example 4] Export the keywords starting with CJH to the registry database and name them.
regedit /E cjh
[Example 5] Specify that system/dat is stored in D:\PWIN and in E:\PWIN, and the data file is formed into a new registry database registry.
regedit /L:\PWIN /R:E:\PWIN /C
With the above knowledge, combined with the import or exported registry files (*.REG) mentioned in "Shortcuts for Programming Registry", we can program the registry in DOS mode.
Let’s take the example of changing the default opening method of the “*.txt” file—“Notepad” as “Writing Board”. First, export the subkey "HKEY_CLASSES_ROOT\txtfile" at the MS-DOS prompt, that is, execute the command:
regedit /E HKEY_CLASSES_ROOT\txtfile
Then use the EDIT editor under DOS to open the file and edit it: Change all "C:\\WINDOWS\\" into "C:\\WINDOWS\\", save the disk and exit EDIT, and then execute the command on the command line:
regedit
Then the work was done.
Of course, strictly speaking, this is not programming. If you have to program and implement it, we can write the above process into a batch of processing files:
@echo off
path=c:\windows;c:\windows\command;c:\dos
cls
echo is exporting the registry...
regedit /E HKEY_CLASSES_ROOT\txtfile
echo.
The echo registry is exported! Press any button to start editing the registry...
echo.
pause
edit
echo is importing the modified registry...
regedit
echo Congratulations! The registry was successfully modified under MS-DOS mode!
pause
cls
@echo on
To give full play to the powerful functions of the EDIT editor, we can modify, delete or add any subkey to the registry as we wish while following the format of the exported registry file. If you think this is not programmatic enough, you can take advantage of the advantages of various programming languages in the DOS environment, plus the interactive interface, and truly programmatic this process should be no less than the effect of using API functions in Windows. Interested friends can give it a try. If you have any questions about this, please contact me (acalpdc@).
Type the Regedit command at the DOS prompt and a help screen will appear. This screen gives its command line parameters and how to use it.
Syntax: Regedit [/L:system] [/R:user] filename1
Regedit [/L:system] [/R:user] /C filename2
Regedit [/L:system] [/R:user] /E filename3 [regpath]
in:
/L:system Specifies the storage location of the file.
/L:user Specifies the storage location of the file.
filename1 Specifies the file name to introduce the registry database.
/C filename2 Specifies the file name that forms the registry database.
/E filename3 Specifies the file name for exporting the registry file.
regpath specifies the start keyword for exporting the registry file (default is all keywords)
Let me give you a few examples to illustrate how to use it in DOS.
[Example 1] Export the system registry database registry to a file.
regedit /E
[Example 2] Form the system registry database registry (all).
regedit /C
[Example 3] It will be introduced into the system registry database (partial).
regedit
[Example 4] Export the keywords starting with CJH to the registry database and name them.
regedit /E cjh
[Example 5] Specify that system/dat is stored in D:\PWIN and in E:\PWIN, and the data file is formed into a new registry database registry.
regedit /L:\PWIN /R:E:\PWIN /C
With the above knowledge, combined with the import or exported registry files (*.REG) mentioned in "Shortcuts for Programming Registry", we can program the registry in DOS mode.
Let’s take the example of changing the default opening method of the “*.txt” file—“Notepad” as “Writing Board”. First, export the subkey "HKEY_CLASSES_ROOT\txtfile" at the MS-DOS prompt, that is, execute the command:
regedit /E HKEY_CLASSES_ROOT\txtfile
Then use the EDIT editor under DOS to open the file and edit it: Change all "C:\\WINDOWS\\" into "C:\\WINDOWS\\", save the disk and exit EDIT, and then execute the command on the command line:
regedit
Then the work was done.
Of course, strictly speaking, this is not programming. If you have to program and implement it, we can write the above process into a batch of processing files:
@echo off
path=c:\windows;c:\windows\command;c:\dos
cls
echo is exporting the registry...
regedit /E HKEY_CLASSES_ROOT\txtfile
echo.
The echo registry is exported! Press any button to start editing the registry...
echo.
pause
edit
echo is importing the modified registry...
regedit
echo Congratulations! The registry was successfully modified under MS-DOS mode!
pause
cls
@echo on
To give full play to the powerful functions of the EDIT editor, we can modify, delete or add any subkey to the registry as we wish while following the format of the exported registry file. If you think this is not programmatic enough, you can take advantage of the advantages of various programming languages in the DOS environment, plus the interactive interface, and truly programmatic this process should be no less than the effect of using API functions in Windows. Interested friends can give it a try. If you have any questions about this, please contact me (acalpdc@).