Jump to content

Editing registry


Recommended Posts

Hi

I am de commissioning a server and moving the data to another. Unfortunately the majority of users have drives mapped locally on their PC's which will have to be re-mapped to the new location.

My thinking was along these lines:

read the key into an array (RegEnumKey), compare the value and overwrite if match occurs.

I used the RegEnumKey example as a basis and added a RegRead but it isn't working at all. Can anyone offer any ideas?

thx

For $i= 1 to 10
    $var = RegEnumKey("HKEY_CURRENT_USER\Network\", $i)
    If @error <> 0 then ExitLoop
    _read()
    Next

Func _read()
    $dr1 = RegRead("HKEY_CURRENT_USER\Network\" & $i, "RemotePath")
    MsgBox(0, "Test", $dr1)
EndFunc

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Link to comment
Share on other sites

1) You have to use the fetched key, not the counter variable

2) use Function Parameters muttley

3) use a while-loop, so the amount of keys is not limited :)

$i = 0
While 1
    $i += 1
    $var = RegEnumKey("HKEY_CURRENT_USER\Network\", $i)
    If @error <> 0 then ExitLoop
    _read($var)
WEnd

Func _read($key)
    $dr1 = RegRead("HKEY_CURRENT_USER\Network\" & $key, "RemotePath")
    MsgBox(0, "Test", $dr1)
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Hi ProgAndy,

Thanks for this, it has pointed me in the right direction at least, however I still have a bit of a problem...maybe you could help.

I added to your script to re write the value but for some reason it isn't doing it. Am I missing something obvious/being stupid/not getting the point here (del as necessary)

thx again

$old = "\\intranet\it_mgmt"
$new = "\\newsvr\newshare"

$i = 0
While 1
    $i += 1
    $var = RegEnumKey("HKEY_CURRENT_USER\Network\", $i)
    If @error <> 0 then ExitLoop
    _read($var)
WEnd

Func _read($key)
    $dr1 = RegRead("HKEY_CURRENT_USER\Network\" & $key, "RemotePath")
    If $dr1 = $old Then
        RegWrite("HKEY_CURRENT_USER\Network\" & $key & "\Remotepath", "REG_SZ", $new)
        MsgBox(0, "Test", $dr1)
    EndIf
EndFunc

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

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...