Jump to content

setting a regkey when the keyname (guid) is dynamic??


Shadster
 Share

Recommended Posts

Hi All,

Trying to change a couple regkeys in which the full key name is dynamic from build to build and i am not sure how to really parse it.

need to change the dword value of "NetbiosOption" to "1" if it exists under this tree:

HKLM\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_{xyz123-12-345-7890}

problem is that the guid... part inside of the curly brackets changes... {xyz123-12-345-7890} from machine to machine with same hardware/image etc...)

so how can i just look for "Tcpip_{* or wildcard equivalent in this branch and then edit it if it is there?

or should i just change my logic and search the reg for the NetbiosOption key and if exists change it to 1? not sure i like the blanket approach since i know that i only want to change the ones under this 'branch'

or should I have it read and set then return values to a variable(s) and then pump it back via something like:"

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\$Variable", "NetbiosOption","Reg_DWORD", "1" )
Link to comment
Share on other sites

yeah, they are for each nic connection...

so i have it reading them, and kicking it to a msg box, and some tenative logic below... but obviously i have some errors when i go to pass it to a the value, and then read the key if a 0 or 1... as well as catching the error if that sub-key (NetbiosOptions) does not exist

$Path = String("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesNetBTParametersInterfaces")
For $i= 1 to 10
    $var = RegEnumKey($Path, $i)
    If @error <> 0 then ExitLoop
    MsgBox(4096, "Tcpip_{xxx} #" & $i & " under HKLMSYSTEMCurrentControlSetServicesNetBTParametersInterfaces: ", $var)

also not sure on if i need the backtrailing slash for the RegEnumVal:

something like this to get that value (then determine if a 0 --change it, else next) but keeps showing blank so not setting/reading it yet... maybe a missing blackslash i.e. $Path''&$var

$val = RegEnumVal($Path1&$var, "NetbiosOptions")
MsgBox(4096, "testwindows", $val)
Edited by Shadster
Link to comment
Share on other sites

Something like this:

$Path = String("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\")

For $i= 1 to 10
    $var = RegEnumKey($Path, $i)
    If @error <> 0 then ExitLoop
    $Search_Val = RegRead($Path & $var,"NetbiosOptions")
    If Not @error Then
        ConsoleWrite($i & @TAB & $var & @TAB & "DWORD: " & $Search_Val & @CRLF)
    Else
        ConsoleWrite($i & @TAB & $var & @TAB & "Not Found" & @CRLF)
    EndIf
Next

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...