'----------------------------------------------------------------------------------------------------------------
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003
strComputer = "."
Set WShell = CreateObject( "WScript.Shell")
Set FSO = CreateObject( "Scripting.FileSystemObject")
Set WNetwork = CreateObject("WScript.Network")
'----------------------------------------------------------------------------------------------------------------
Set objRegistry=GetObject( "winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
Set objReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'----------------------------------------------------------------------------------------------------------------
For Each objSubkey In arrSubkeys
strValueName = "Volatile Environment"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
Next
strUserName = WNetwork.username
If UCase(strUserName) = "SYSTEM" Then
string1 = "S-1-5-21"
string2 = "Classes"
objReg.EnumKey HKEY_USERS, "", arrsubkeys
For Each Subkey In arrSubKeys
If InStr(1,Subkey, string1,1)And (InStr(1,Subkey, string2,1) = "0") Then
Key = "HKEY_USERS\" & Subkey & "\SOFTWARE\Test Key\Something"
msgbox Key
Wshell.RegWrite Key, "1", "REG_DWORD"
End If
Next
Else
End If
Comments