注册表修改脚本,用脚本文件简单修改注册表

用脚本文件简单修改注册表 - 注册表 - 电脑教程网

用脚本文件简单修改注册表

日期:2006-05-23   荐:

用.VBS脚本,也就是SCRIPT 脚本文件对注册表进行修改。如果您的爱机不支持VBSCRIPT,那么请您直接阅读第二部分。下面我通过一个例子自来解释脚本文件:

Windows Script Host Sample Script

You have a royalty-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.

L_Welcome_MsgBox_Message_Text = "此脚本显示如何创建和删除注册表项。"

L_Welcome_MsgBox_Title_Text = "Windows Scripting Host 范例"


Call Welcome()

********************************************************************************

*

* Registry related methods.

*

 

Dim WSHShell

Set WSHShell = WScript.CreateObject("WScript.Shell")

 

WSHShell.Popup "创建项 HKCUMyRegKey 数值为 Top level key"

WSHShell.RegWrite "HKCUMyRegKey", "Top level key"

 

WSHShell.Popup "创建项 HKCUMyRegKeyEntry 数值为 Second level key"

WSHShell.RegWrite "HKCUMyRegKeyEntry", "Second level key"

 

WSHShell.Popup "将数值项 HKCUMyRegKeyValue 设为 REG_SZ 1"

WSHShell.RegWrite "HKCUMyRegKeyValue", 1

 

WSHShell.Popup "将数值项 HKCUMyRegKeyEntry 设为 REG_DWord 2"

WSHShell.RegWrite "HKCUMyRegKeyEntry", 2, "REG_DWORD"

 

WSHShell.Popup "将数值项 HKCUMyRegKeyEntryValue1 设为 REG_BINARY 3"

WSHShell.RegWrite "HKCUMyRegKeyEntryValue1", 3, "REG_BINARY"

 

WSHShell.Popup ot;删除 HKCUMyRegKeyEntryValue1 数值"

WSHShell.RegDelete "HKCUMyRegKeyEntryValue1"

 

WSHShell.Popup "删除 HKCUMyRegKeyEntry 项"

WSHShell.RegDelete "HKCUMyRegKeyEntry"

 

WSHShell.Popup "删除 HKCUMyRegKey 项"

WSHShell.RegDelete "HKCUMyRegKey"

 

********************************************************************************

*

* Welcome

*

Sub Welcome()

Dim intDoIt

 

intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _

vbOKCancel + vbInformation, _

L_Welcome_MsgBox_Title_Text )

If intDoIt = vbCancel Then

WScript.Quit

End If

End Sub

1.在上例中,单引号后面是注释.

2. L_Welcome_MsgBox_Message_Text = "此脚本显示如何创建和删除注册表项。"

L_Welcome_MsgBox_Title_Text = "Windows Scripting Host 范例"

这两句是提示.

3. 用 Set WSHShell = WScript.CreateObject("WScript.Shell"),定义一个对象WSHSHELL 为WScript.Shell,

 

4.WELCOME()是一个确认对话框.

5. WSHShell.Popup "创建项 HKCUMyRegKey 数值为 Top level key" 是声明要修改的注册表项.

WSHShell.RegWrite "HKCUMyRegKey", "Top level key" 在HKCU下面创建MYREGKEY子键,读者也可以根据自己实际情况修改键名、指定路径。

6、REG_SZ为字符串,要用引号引起来,REG_DWORD 为0—2147483647之间整数,REG_BINARY与之范围相同。

7、需要注意的是,若结尾是“”则创建一个主键(项),将其默认值设为逗号后面的值项,若结尾不是“”,则在前一个“”后面的项中建立所设立的VALUE,逗号后面为其值。

8、WSHShell.RegDelete与WSHShell.RegWrite大致相同,只是功能相反。

各位可以将上面文档复制,存为FILENAME.VBS,然后双击即可。



[1] [2]  

用INF 脚本修改注册表。同样我先举一个例子,然后做详细讲解。


[VERSION]

SIGNATURE=$CHICAGO$

 

[DEFAULTINSTALL]

ADDREG=MY.ADD.REG

DELREG=MY.DEL.REG

 

[MY.ADD.REG]

HKLM,SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONWINLOGON,AUTOADMINLOGON,0,”0”

HKCU,CONTROL PANELDESKTOP,SMOOTHSCROLL,1,01,00,00,00

HKCU,CONTROL PANELDESKTOP,SCREENSAVEUSEPASSWORD,1,00,00,00,00

 

[MY.DEL.REG]

HKCU,MYKEY

HKLM,SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONWINLOGON,DEFAULTUSERNAME

HKLM,SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONWINLOGON,DEFAULTUSERNAME

 

1.[VERSION] 是文件头。

SIGNATURE=$CHICAGO$ 是指针对WINDOWS(CHICAGO是WINDOWS95的内部名称)

要编辑注册表必须以这两句开头。

  2、[DEFAULTINSTALL]段指出INF文件包含的其他段,ADDREG 和DELREG是键,有特殊意义,他指出要添加或删除的注册表项段名

  3、WINDOWS98总是先处理DELREG段,后处理ADDREG段,这可能会对我们的应用有所帮助。

  [MY.ADD.REG]

  HKCU,MYKEY,MYVALUE,0,“STRING” 添加名为MYVALUE的字符串值项到键MYKEY下,其值设为STRING

  HKCU,MYKEY,MYVALUE,,STRING 添加名为MYVALUE的字符串值项到MYKEY,将其值设为STRING

  HKCU,MYKEY,MYVALUE,1,77,34,05,20添加名为MYVALUE的二进制值项到键MYKEY下,其值设为二进制值77,34,05,20

  HKCU,MYKEY,0,”DEFAULT VALUE” 设置键MYKEY的缺省值项为字符串DEFAULT VALUE

  HKCU,MYKEY,,”DEFAULT VALUE” 设置键MYKEY的缺省值项并将其值设为字符串DEFAULT VALUE

  HKCU,MYKEY 添加注册表键MYKEY但不设置其值

 

  [MY.DEL.REG]

  HKCU,MYKEY,MYVALUE 从键MYKEY 中删除值项MYVALUE

  HKCU,MYKEY 删除键MYKEY及其全部子键,即删除全部分支.

 

  下面是一个自动清除MRU记录的INF文件:

  CLEAN.INF

  [VERSION]

  SIGNATURE=$CHICAGO$

 

  [DEFAULTINSTALL]

  DELREG=DELTEGKEY

 

  [DELREGKEY]

  HKCU,”SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONEXPLORERDOC FIND SPEC MRU”,

  HKCU, SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONEXPLORERFINDCOMPUTERMRU,

  HKCU, SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONEXPLORERRECENTDOCS,

  HKCU, SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONEXPLORERRUNMRU

 

  清除MRU和WINDOWSRENCENT 的批处理文件

  CLEAN.BAT

  @ECHO OFF

  C:WINDOWSRUNDLL.EXE SETUPX.DLL,INSTALLHINFSECTION DEFAULTINSTALL 132 CLEAN.INF

  ECHOY ERASE C:WINDOWSRECENT


  各位可将CLEAN.BAT 加入HKEY_LOCAL_MACHINESOFTWAREMICROSOFTWINDOWSCURRENTVERSIONRUN中让电脑自动在启动时完成任务.

 

(出处:http://www.sheup.com)


 [1] [2] 

  各位可将CLEAN.BAT 加入HKEY_LOCAL_MACHINESOFTWAREMICROSOFTWINDOWSCURRENTVERSIONRUN中让电脑自动在启动时完成任务.

 

(出处:http://www.sheup.com/)


 [1] [2] [3] 

标签: