Vbscript 使用VBS删除注册表文件夹和子文件夹

Vbscript 使用VBS删除注册表文件夹和子文件夹,vbscript,Vbscript,我想用vb脚本删除注册表文件夹及其下的子文件夹 在reg文件中,我们可以编写如下脚本: [-HKEY_LOCAL_MACHINE\SOFTWARE\abc\prr] 上面的脚本将删除prr下的子文件夹 如何使用VB脚本实现同样的功能 我尝试使用.RegDelete,但我认为它只对注册表项有效,而对注册表文件夹无效 谢谢。[path]RegDelete[Key]|[Value] RegDelete的路径,以便Windows可以找到它。请参阅Windows 98提示和黑客页面上的提示,以使Wind

我想用vb脚本删除注册表文件夹及其下的子文件夹

在reg文件中,我们可以编写如下脚本:

[-HKEY_LOCAL_MACHINE\SOFTWARE\abc\prr]
上面的脚本将删除prr下的子文件夹

如何使用VB脚本实现同样的功能

我尝试使用.RegDelete,但我认为它只对注册表项有效,而对注册表文件夹无效


谢谢。

[path]RegDelete[Key]|[Value]

RegDelete的路径,以便Windows可以找到它。请参阅Windows 98提示和黑客页面上的提示,以使Windows始终找到它

没有任何内容会使用用户界面启动RegDelete。键入要删除的键或值时,不要将键或值用倒逗号括起来

输入要删除的键。关键点总是以反斜杠结尾。如果密钥包含空格,则必须用倒逗号将其括起来。密钥和子密钥将被删除

值要删除的值。值后面没有反斜杠。如果密钥包含空格,则必须用倒逗号将其括起来

将以下行复制到新文本文档中,并另存为RegDelete.vbs

'RegDelete.vbs
'Deletes keys or values from the registry.
'
'
On Error Resume Next
vbPara=vbCRLF & vbCRLF
strExplain="RegDelete deletes keys and values from the registry." & vbPara & "Keys must end with a backspace and values must not." & vbPara & "Start without parameters to type in a key or value to delete, or place the key or value on the command line (use inverted commas to surround the key or value if it contains spaces)."  & vbPara & "Continue"
strTitle="Reg Delete"
Key=""
Dim silent
Silent=""

Dim Sh
Set Sh = WScript.CreateObject("WScript.Shell")
ReportErrors "Creating Shell"

Key=GetKey()
If Key<>"" then 
    B=Sh.RegRead (Key)
    If Err.Number=0 Then 
        Sh.RegDelete Key
        If Err.Number =0 Then 
            If silent<>"yes" Then MsgBox Key & " deleted", vbOKOnly + vbInformation, strTitle
        Else
            ReportErrors "DeletingKey"
        End If
    Else
        If Err.Number=-2147024893 then 
            Err.Clear
            MsgBox Key & " didn't exist", vbOKOnly + vbCritical, strTitle
        Else
            ReportErrors "Reading before Deleting Key"
        End If
    End If
End If

ReportErrors "Main"

Function GetKey()
    Dim Ag
    Set Ag=Wscript.Arguments
    ReportErrors "Creating Aguments"
    If Ag.Count=1 then GetKey=Ag(0)
    Silent="yes"
    If Ag.Count >1 then sgBox "Too many parameters on command line. Try enclosing the key in a space",vbOKOnly + vbCritical, strTitle

    If Ag.Count=0 then 
        If MsgBox (strExplain, vbYesNo + vbInformation, strTitle)=6 Then
            GetKey=InputBox ("Enter the value or key to delete." & vbPara & "Keys must end in a backspace.", strTitle, strNamet1)
        End If
    End If
End Function

Sub ReportErrors(strModuleName)
    If err.number<>0 then Msgbox "Error occured in " & strModuleName & " module of " & err.number& " - " & err.description & " type" , vbCritical + vbOKOnly, "Something unexpected"
    Err.clear
End Sub

Regdelete。如果以\结尾,则必须是键。否\然后选择一个值。键是文件夹。@tony bd:Not working不工作的内容-Sh.RegDelete HKCR\.txt\删除键Sh.RegDelete HKCR\.txt\ShellNew删除ShellNew键的默认值,Sh.RegDelete HKCR\.txt\ShellNew\NullFile删除名为NullFile的值。