以下代码旨在从 HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ ProfileList
中删除所有用户帐户代码:
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
strPath=Left(strvalue,Len(strvalue)-Len(Right(strvalue,Len(strvalue)-9)))
strID=Right(strvalue,Len(strvalue)-9)
if ((strPath="C:\Users\") and (strID<>"rcadmin")) then
return=objRegistry.DeleteKey(HKEY_LOCAL_MACHINE, strSubPath)
end if
Next
wscript.echo "Done"
如果我将“return=objRegistry.DeleteKey(HKEY_LOCAL_MACHINE, strSubPath)
”替换为“wscript.echo strID
”,则会显示我的预期。所以我现在需要做的就是从“ HKEY_LOCAL_MACHINE ”中删除字符串“ strSubPath ”。这是我无法做到的部分。
的输出示例
wscript.echo strSubPath" is "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"\S-1-5-21-3469983464-63224933-1422604425-8029
我错过了什么?