Code for operations on the registry in DOS mode

Source: Internet
Author: User

Because the Registration Table editor regedit.exe is actually a dual-habitat type Program Can be run in DOS or Windows 95/98. Many users may already know how to use Regedit in windows. To learn how to program the Registry in DOS mode, first understand how to use the Registry Editor in DOS.
Enter the Regedit command at the DOS prompt. A help screen is displayed. This screen provides its command line parameters and usage methods.
Syntax: Regedit [/L: system] [/R: User] filename1
Regedit [/L: system] [/R: User]/C filename2
Regedit [/L: system] [/R: User]/e filename3 [regpath]
Where:
/L: system specifies the storage location of the system. dat file.
/L: The User specifies the storage location of the user. dat file.
Filename1 specifies the name of the file that introduces the registry database.
/C filename2 specifies the file name that forms the registry database.
/E filename3 specifies the file name of the exported registry file.
Regpath specifies the start keyword for exporting the Registry File (all keywords by default)
The following example shows how to use regedit.exe in DOS.
[Example 1] export the registry of the system registry database to the reg1.reg file.
Regedit/e reg1.reg
[Example 2] reg1.reg forms the registry of the system registry database (all.
Regedit/C reg1.reg
[Example 3] introduce Reg. dat into the system registry database (partial ).
Regedit Reg. dat
[Example 4] export the key word starting with C6. name it C6. Reg.
Regedit/e cworkflow. Reg cworkflow
[Example 5] specify to store system/dat in D: \ pwin and user. dat in E: \ pwin, and form a new registry database by using the reg. dat data file.
Regedit/L: \ pwin/R: e: \ pwin/C Reg. dat

With the above knowledge, combined with the import or export of the Registry File (*. reg), we can program the Registry in DOS mode.

Let's take the default Opening Method of the "*. txt" file-"Notepad" as an example. First export the "hkey_classes_root \ txtfile" sub-key branch at the MS-DOS prompt, that is, execute the command:

Regedit/e TXT. Reg hkey_classes_root \ txtfile

Open the TXT file in the edit editor under DOS. edit the reg file: replace all "C: \ Windows \ notepad. change EXE to c: \ Windows \ write. EXE ", save the disk and exit edit, and then execute the command in the command line:

Regedit TXT. Reg

This is all done.
Of course, strictly speaking, this is not programming. If programming is required, we can write the above process as a batch of processing files 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 completed! Edit the Registry with one click ......
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

make full use of the powerful functions of the edit editor. We can modify, delete, or add any sub-keys to the registry while following the exported registry file format. If you think this is not procedural enough, you can take advantage of the advantages of various programming languages in the DOS environment, coupled with interactive interfaces, to truly program this process, it should be no less effective than using API functions in windows. If you are interested, try it. 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.