用VBScript修改注册表,必须先创建一个能于操作系统沟通的对象,再利用该对象的各种方法对注册表进行操作,创建这个对象的方法和格式如下:
Dim OperationRegistry
Set OperationRegistry=WScript.CreateObject("WScript.Shell")
上述这些代码就创建了一个能与操作系统沟通的对象OperationRegistry
'delete.vbs
Dim OperationRegistry
Set OperationRegistry=WScript.CreateObject("WScript.Shell")
OperationRegistry.RegRead("HKCR\.xxf\value")
'删除.xxf主键之下的value键值
OperationRegistry.RegRead("HKCR\.xxf\")
'删除根键HKEY_CLASSES_ROOT之下的.xxf主键
'ReadComputerName.vbs
Dim ReadComputerName
Set ReadComputerName=WScript.CreateObject("WScript.Shell")
Dim ComputerName,RegPath
RegPath="HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
ComputerName=ReadComputerName.RegRead(RegPath)
MsgBox("计算机名为"&ComputerName)
2、隐藏快捷方式图标上的小箭头
'Hidden.vbs
Dim HiddenArrowIcon
Set HiddenArrowIcon=WScript.CreateObject("WScript.Shell")
Dim RegPath1,RegPath2
RegPath1="HKCR\lnkfile\IsShortCut"
RegPath2="HKCR\piffile\IsShortCut"
HiddenArrowIcon.RegDelete(RegPath1)
HiddenArrowIcon.RegDelete(RegPath2)
3、改造“开始”菜单
'ChangeStartMenu.vbs
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1