Use the. vbs script, that is, the SCRIPT file, to modify the registry. If your machine does not support VBSCRIPT, read the second part. The following example is used to explain the script file:
Windows Script Host Sample Script
You have a maid-free right to use, modify, reproduce and distribute
The Sample Application Files (and/or any modified version) in any way
You find useful, provided that you agree that Microsoft has no warranty,
Obligations or liability for any Sample Application Files.
------------------------------------------------------------------------
This sample demonstrates how to write/delete entries in the registry.
Rochelle welcome_msgbox_message_text = "this script shows how to create and delete a registry key. "
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host example"
Call Welcome ()
**************************************** ****************************************
*
* Registry related methods.
*
Dim WSHShell
Set WSHShell = WScript. CreateObject ("WScript. Shell ")
WSHShell. Popup "The HKCU \ MyRegKey value is the Top level key"
WSHShell. RegWrite "HKCU \ MyRegKey \", "Top level key"
WSHShell. Popup "create item HKCU \ MyRegKey \ Entry value is Second level key"
WSHShell. RegWrite "HKCU \ MyRegKey \ Entry \", "Second level key"
WSHShell. Popup "set the Value item HKCU \ MyRegKey \ Value to REG_SZ 1"
WSHShell. RegWrite "HKCU \ MyRegKey \ Value", 1
WSHShell. Popup "set the value item HKCU \ MyRegKey \ Entry to REG_DWORD 2"
WSHShell. RegWrite "HKCU \ MyRegKey \ Entry", 2, "REG_DWORD"
WSHShell. Popup "set the value item HKCU \ MyRegKey \ Entry \ Value1 to REG_BINARY 3"
WSHShell. RegWrite "HKCU \ MyRegKey \ Entry \ Value1", 3, "REG_BINARY"
WSHShell. Popup ot; Delete HKCU \ MyRegKey \ Entry \ Value1 value"
WSHShell. RegDelete "HKCU \ MyRegKey \ Entry \ Value1"
WSHShell. Popup "deleting HKCU \ MyRegKey \ Entry"
WSHShell. RegDelete "HKCU \ MyRegKey \ Entry \"
WSHShell. Popup "delete HKCU \ MyRegKey entry"
WSHShell. RegDelete "HKCU \ MyRegKey \"
**************************************** ****************************************
*
* Welcome
*
Sub Welcome ()
Dim intDoIt
IntDoIt = MsgBox (L_Welcome_MsgBox_Message_Text ,_
VbOKCancel + vbInformation ,_
Rochelle welcome_msgbox_title_text)
If intDoIt = vbCancel Then
WScript. Quit
End If
End Sub
1. In the above example, single quotes are followed by comments.
2. L_Welcome_MsgBox_Message_Text = "this script shows how to create and delete a registry key. "
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host example"
These two statements are prompts.
3. Use Set WSHShell = WScript. CreateObject ("WScript. Shell") to define an object WSHSHELL as WScript. Shell,
4. WELCOME () is a confirmation dialog box.
5. WSHShell. Popup "create the HKCU \ MyRegKey value as Top level key" is the registry key to be modified.
WSHShell. RegWrite "HKCU \ MyRegKey \", "Top level key" create the MYREGKEY sub-key under HKCU. You can also modify the key name and specify the path based on your actual situation.
6. REG_SZ is a string that is enclosed in quotation marks. REG_DWORD is an integer between 0-2147483647 and the range of REG_BINARY is the same.
7. Note that if the end is "\", a primary key item is created.) set the default value to the value item after the comma. If the end is not "\", then, the set VALUE is created in the item following the previous "\", and the VALUE is followed by a comma.
8. WSHShell. RegDelete and WSHShell. RegWrite are roughly the same, but the function is opposite.
You can copy the above document, save it as FILENAME. VBS, and double-click it.
Use the INF script to modify the registry. Let me give an example and explain it in detail.
[VERSION]
SIGNATURE = $ CHICAGO $
[Defainstall install]
ADDREG = MY. ADD. REG
DELREG = MY. DEL. REG
[MY. ADD. REG]
HKLM, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ WINLOGON, AUTOADMINLOGON, 0, "0"
HKCU, control panel \ DESKTOP, SMOOTHSCROLL, 00
HKCU, control panel \ DESKTOP, SCREENSAVEUSEPASSWORD, 00
[MY. DEL. REG]
HKCU, MYKEY
HKLM, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ WINLOGON, DEFAULTUSERNAME
HKLM, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ WINLOGON, DEFAULTUSERNAME
1. [VERSION] is the file header.
SIGNATURE = $ CHICAGO $ is the internal name of WINDOWS95 for WINDOWSCHICAGO)
To edit the registry, you must start with these two sentences.
2. The [defainstall install] section indicates other segments contained in the INF file. ADDREG and DELREG are keys and have special meanings. It indicates the registry key segment name to be added or deleted.
3. In Windows 98, DELREG and ADDREG segments are always processed first, which may be helpful to our applications.
[MY. ADD. REG]
HKCU, MYKEY, MYVALUE, 0, and "STRING" add a STRING value item named MYVALUE to the key MYKEY, whose value is set to STRING
HKCU, MYKEY, MYVALUE, and STRING Add a STRING value item named MYVALUE to MYKEY and set its value to STRING
HKCU, MYKEY, MYVALUE, 20 Add the binary value entry named MYVALUE to the key MYKEY. The value is set to the binary value ,.
HKCU, MYKEY, 0, "default value" sets the default value of the key MYKEY as the string default value.
HKCU, MYKEY, and "default value" set the default value of the key MYKEY and set its VALUE to the string default value.
HKCU and MYKEY Add the registry key MYKEY but do not set its value
[MY. DEL. REG]
HKCU, MYKEY, and MYVALUE Delete the value item MYVALUE from the key MYKEY
HKCU, MYKEY deletion key, MYKEY, and all its subkeys are deleted.
The following is an INF file that automatically clears MRU records:
CLEAN. INF
[VERSION]
SIGNATURE = $ CHICAGO $
[Defainstall install]
DELREG = DELTEGKEY
[DELREGKEY]
HKCU, "SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ EXPLORER \ doc find spec mru ",
HKCU, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ EXPLORER \ FINDCOMPUTERMRU,
HKCU, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ EXPLORER \ RECENTDOCS,
HKCU, SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ EXPLORER \ RUNMRU
Clear the batch files of MRU and WINDOWS \ RENCENT
CLEAN. BAT
@ ECHO OFF
C: \ WINDOWS \ RUNDLL. exe setupx. DLL, installhinfsection defaultinstall 132 CLEAN. INF
ECHOY | erase c: \ WINDOWS \ RECENT
You can add CLEAN. BAT to HKEY_LOCAL_MACHINE \ SOFTWARE \ MICROSOFT \ WINDOWS \ CURRENTVERSION \ RUN to automatically complete the task at startup.