关于删除注册表项和子项 [英] About Delete Registrykeys and subkeys
问题描述
您好,脚本专家!
我遇到了一个我尝试创建的vbscript问题。我将创建一个脚本,它将从数组中删除registrykeys及其子键。但是当我尝试运行脚本时出现语法错误。有人看到我做错了吗?
脚本将在那里停止子程序开始。
结果:
C:\ removeFromRegistry.vbs(31,3)Microsoft VBScript编译错误:语法e
rror
最好的问候
Emil
OPTION EXPLICIT
Dim RegToDelete,strComputer,objRegistry,strRegPath, arrKeys,strRegHive
Const HKEY_CLASSES_ROOT =& H80000000
Const HKEY_CURRENT_USER =& H80000001
Const HKEY_LOCAL_MACHINE =& H80000002
Const HKEY_USERS =& H80000003
Const HKEY_CURRENT_CONFIG =& H80000005
strComputer ="。"
RegToDelete = Array(" HKEY_CURRENT_USER \Software\Autodesk \ Inventor \RegistryVersion16.0",$
" HKEY_LOCAL_MACHINE \Software \ Autodesk \ Invoror \ RegistryVersion16.0",_
" HKEY_CURRENT_USER \Software\Autodesk \ Inventor\RegistryVersion16.0",$
" HKEY_CURRENT_USER \Software\Autodesk \ Inventor \RegistryVersion16。 0",_
" HKEY_CURRENT_USER \Software \Autodesk \ Inventor \RegistryVersion16.0",$
" HKEY_CURRENT_USER \Software\Autodesk \ Inventor \RegistryVersion16.0" _
)
设置objRegistry = GetObject(" winmgmts:\\"& _
strComputer&" \root \ default:StdRegProv" )
每个strRegPath在RegToDelete
strRegHive = Left(strRegPath,17)
strRegPath = Replace(strRegPath," HKEY_CURRENT_USER \","")
DeleteSubkeys strRegHive,strRegPath
Sub DeleteSubkeys(strRegHive,strRegPath)
objRegistry.EnumKey strRegHive,strRegPath,arrSubkeys
If IsArray(arrSubkeys)Then
For each strSubkey in arrSubkeys
DeleteSubkeys strRegHive,strRegPath& " \" &安培; strSubkey
Next
End if
'objRegistry.DeleteKey Left(strRegPath,18),Replace(strRegPath," HKEY_CURRENT_USER",""),arrSubkeys& " \" &安培; strSubkey
结束子
下一个
嗨aramiz,
抱歉,你的论坛错误。
试试:http://social.technet.microsoft.com/Forums/en-US/ITCG /线程
Hello, scripting gurus!
I have got some problem with one of mine vbscript I tried to create. I will create a script that will remove registrykeys and it's subkeys from an array. But got syntax error when I try to run the script. Do someone see what I'm doing wrong?
Script will stop at line there Subroutine begin.
Result:
C:\removeFromRegistry.vbs(31, 3) Microsoft VBScript compilation error: Syntax e
rror
Best Regards
Emil
OPTION EXPLICIT
Dim RegToDelete, strComputer, objRegistry, strRegPath, arrKeys, strRegHive
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
strComputer = "."
RegToDelete = Array("HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion16.0",_
"HKEY_LOCAL_MACHINE\Software\Autodesk\Inventor\RegistryVersion16.0",_
"HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion16.0",_
"HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion16.0",_
"HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion16.0",_
"HKEY_CURRENT_USER\Software\Autodesk\Inventor\RegistryVersion16.0"_
)
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
For Each strRegPath In RegToDelete
strRegHive = Left(strRegPath, 17)
strRegPath = Replace(strRegPath, "HKEY_CURRENT_USER\", "")
DeleteSubkeys strRegHive, strRegPath
Sub DeleteSubkeys(strRegHive, strRegPath)
objRegistry.EnumKey strRegHive, strRegPath, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys strRegHive, strRegPath & "\" & strSubkey
Next
End If
'objRegistry.DeleteKey Left(strRegPath, 18),Replace(strRegPath, "HKEY_CURRENT_USER", ""), arrSubkeys & "\" & strSubkey
End Sub
Next
Hi aramiz,
Sorry, but you got the wrong forum.
Try: http://social.technet.microsoft.com/Forums/en-US/ITCG/threads
这篇关于关于删除注册表项和子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!