Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the value of a registry entry

Status
Not open for further replies.

caffrinho

MIS
Mar 1, 2002
91
GB
Hi,

I'm looking to change the value of a registry key, it's location is unknown so i need to search for it first.
It's name is 001e6608 type REG_SZ and has a default value of 100.

I've looked at MS Scripting center and googled for solutions, but i can't find anything that doesn't assume you KNOW the path first.

It's somewhere in HKCU\Software\Microsoft\

After that it depends on OS, plus it's(as far as i can tell) a randomly generated key name.

Hope somebody can point me in the right direction,

Cheers

 
thanks for that.

It doesn't say how to find the key i'm after though, (Unless i'm missing something) which is where i'm stuck
 
Look at EnumKey

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
As said, all i want to do is change the data of value 001e6608 from 100 to (say) 500. The scope has changed slightly as i've realised i don't need to worry about win9x. The key is still unknown however. It resides in:

Code:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<profile name>\xxxxxx

Profile Name varies and xxxxxx is a hex value that also varies.
 
It's a bit long winded, but...

Code:
Option Explicit

Const HKCU = &H80000001
Dim strComputer, objReg, strKeyPath
Dim arrSubKeys, subKey
Dim strSubKey
Dim StrProfilePath
Dim arrProfSubKeys, profKey
Dim strFinalPath
Dim arrValueNames, arrValueTypes
Dim strValue
Dim rtnValueSet, intReturn, i


strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

objReg.EnumKey HKCU, strKeyPath, arrSubKeys

For Each subKey In arrSubKeys
    strSubKey = subKey
    
    StrProfilePath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & strSubKey
    
    objReg.EnumKey HKCU, StrProfilePath, arrProfSubKeys
    
    For Each profKey In arrProfSubKeys
    
            On Error Resume Next
            strFinalPath = StrProfilePath & "\" & profKey
            
            objReg.EnumValues HKCU, strFinalPath, arrValueNames, arrValueTypes
            For i = 0 To UBound(arrValueNames)
            If arrValueNames(i) = "001e6608" Then
                    intReturn = objReg.GetStringValue(HKCU, strFinalPath, arrValueNames(i), strValue)
                    If strValue <= 499 Then
                            rtnValueSet = objReg.SetStringValue(HKCU, strFinalPath, arrValueNames(i), 500)
                    End If
            End If
           Next
    Next

Next

If anybody can see potential improvements, please shout!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top