如何删除注册表项及其子项的数组

时间:2012-11-27 13:15:37

标签: vbscript registry

我正在尝试删除注册表项及其子项的数组。

以下是我的代码

Function DeleteSubkeys(strKeyPath) 

    Msgbox"DeleteSubkeys starts "   

    Dim strComputer,arrSubkeys
    Const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set objRegistry = GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv") 

    objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys 

    If IsArray(arrSubkeys) Then 
        For Each strSubkey In arrSubkeys 
            DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey 
        Next 
    End If 

    objRegistry.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

    Msgbox"DeleteSubkeys ends "

    DeleteSubkeys= null

End Function

Msgbox"Main starts "
dim Regkey 
Regkey = Array(_
    "SOFTWARE\Wow6432Node\Myproj\test1",_
    "SOFTWARE\Wow6432Node\Myproj\test2"_
)


Msgbox"Outside foreach "
For Each strRegKey IN Regkey
    Msgbox"Inside foreach  "
        DeleteSubkeys strRegKey
Next

Msgbox"Main ends "

但它无法调用在forach中调用的函数DeleteSubKeys。我在这里缺少什么?

0 个答案:

没有答案
相关问题