Code to manipulate the registry in DOS mode _dos/bat

Source: Internet
Author: User
Because Registry Editor Regedit.exe is actually a dual-Habitat program that can run either in DOS or under WINDOWS95/98. Many users may already know how to use the Regedit method under Windows, so to master the DOS mode of the registry programming, first of all to understand how to use the Registry Editor in DOS.
Type the regedit command at a DOS prompt, and a help screen appears. This screen gives its command-line arguments and how to use them.
Syntax: Regedit [/l:system] [/r:user] filename1
Regedit [/l:system] [/r:user]/C filename2
Regedit [/l:system] [/r:user]/e filename3 [Regpath]
which
/L:SYSTEM specifies where System.dat files are stored.
/L:USER specifies where User.dat files are stored.
FILENAME1 Specifies the name of the file that introduces the registry database.
/C filename2 Specifies the name of the file that forms the registry database.
/e filename3 Specifies the file name of the exported registry file.
REGPATH Specifies the start keyword for the exported registry file (default is all keywords)
Several examples are given to illustrate the use of Regedit.exe in DOS.
"Example 1" Exports the system registry database registry to the Reg1.reg file.
regedit/e Reg1.reg
"Example 2" Reg1.reg form the system Registry database registry (all).
REGEDIT/C Reg1.reg
"Example 3" introduces Reg.dat to the system registry database (part).
Regedit reg.dat
Example 4 exports the CJH start keyword to the registry database and is named Cjh.reg.
regedit/e Cjh.reg CJH
"Example 5" specifies that System/dat is stored in D:\PWIN and User.dat in E:\PWIN, and reg.dat data files are formed in a new registry database registry.
REGEDIT/L:\PWIN/R:E:\PWIN/C Reg.dat

With all this knowledge, the registry files (*) that are mentioned in the "shortcuts" to programming the registry are discussed. REG), we can program the registry in DOS mode.

Let's also change the default open way for "*.txt" files-Notepad to WordPad for example. You first export the branch of the "Hkey_classes_root\txtfile" subkey at the MS-DOS prompt, which executes the command:

regedit/e Txt.reg Hkey_classes_root\txtfile

Then use the DOS edit editor to open the Txt.reg file for editing: all of them c:\\windows\\notepad. EXE "All changed into" C:\\windows\\write. EXE, save and exit edit, and then execute the command at the command line:

Regedit txt.reg

is done.
Of course, strictly speaking, this is not programming. If you have to do this programmatically, we can write the above process as a batch of file Chang.bat:

@echo off
Path=c:\windows;c:\windows\command;c:\dos
Cls
ECHO is exporting the registry ...
regedit/e Txt.reg Hkey_classes_root\txtfile
Echo.
echo Registry Export complete! Press any key to start editing the registry ...
Echo.
Pause
Edit Txt.reg
ECHO is importing the modified registry ...
Regedit txt.reg
Echo, Congratulations! The registry was successfully modified in MS-DOS mode!
Pause
Cls
@echo on

By giving full play to the powerful features of the edit editor, we can modify, delete, or add any subkey to the registry as we follow the format of the exported registry file. If you think this is not enough programmatic, you can play a DOS environment of the advantages of a variety of programming languages, coupled with interactive interface, the process of real programming, should be no less than the use of Windows State API function to do the effect. Interested friends can have a try. If you have any questions about this, please contact me (acalpdc@sohu.com).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.