Syncing Windows registry between several computers

9

4

There's a certain folder in my Windows XP registry that I would like to be synchronized between my 2 computers, Dropbox-style. The way I want it to be is that every time I make a registry change in one computer, it appears on the other computer(s).

Possible? How?

(If you're curious about why I want to do this: I want to have the same PuTTY sessions on all computers.)

Ram Rachum

Posted 2011-08-25T17:43:50.120

Reputation: 4 261

I have a little idea for something... Can you tell me the exact path of the putty registry keys you want? I am going out now but will be back in about an hour and will try to help further. – William Hilsum – 2011-08-25T17:57:47.777

@William Hilsum: It's HKEY_CURRENT_USER\Software\SimonTatham\PuTTY. – Ram Rachum – 2011-08-25T18:32:01.903

1Are these computers generally on the same network? Or do you want this to work remotely as well? – music2myear – 2011-08-25T19:22:16.573

@Ram Rachum Is that the same on both computers? – William Hilsum – 2011-08-25T19:25:06.700

2

If this is about Putty, Why not use portable putty? It stores the settings in a file. Sync your copies of Portable Putty via dropbox or whatever.

– Zoredache – 2011-08-25T19:42:50.203

@William Hilsum: Yes. – Ram Rachum – 2011-08-25T19:48:09.967

@Zoredache: I checked PortablePutty out. Not bad, syncing a file would be more elegant. But I prefer to use the canonical PuTTY if possible. – Ram Rachum – 2011-08-25T19:53:09.430

@Ram Rachum, Portable putty IS the official version of putty. Download it and run a sha1sum of PuTTYPortable\App\putty\PUTTY.EXE. The sum you get is identical to the official version. The main binary is just doing the registry export/import stuff for you. – Zoredache – 2011-08-25T19:58:52.453

@Zoredache: Just because the putty.exe file delivered by PortablePutty is identical to the original one doesn't mean it's the same program. For example, the portable version doesn't allow you to run side-by-side with the original version. It also doesn't include all the other utilities like pageant.exe and others that come with Putty. – Ram Rachum – 2011-08-27T06:44:51.790

Answers

6

Sorry for taking so long, I think this is the longest I have taken to write an answer!

Ages ago, I wanted very similar functionality, but, I could not find a way of doing it... now that I know quite a bit more programming, I thought it would be worth a try to make something.

So, a few hours later, I give you, RegSync v1.

enter image description here

Simply take a copy of the full registry path (in your case HKEY_CURRENT_USER\Software\SimonTatham\PuTTY) and paste it in to the box.

Click start and it will automatically monitor that registry key for any additions, deletions or changes.

If it detects any changes, it will* export a registry file called regsync.reg in the same folder as the application is running.

* In case of more than one change at a time, it will wait for 5 seconds after the first change.

When/after the start button is pressed, it will monitor the folder it is in for any changes to the regsync.reg file, and if it detects a change, it will delete ALL entries in the registry key you selected locally and import the registry file. (Please be careful, it will not check the .Reg file matches the location it is monitoring, so, if you type different locations on each pc, it may go bad).

So... you can run this from dropbox or windows shares, or any other folder sharing service. Run it on both computers and select the registry key to monitor.

Extra notes...

  • This requires the .NET framework version 4.

  • It does not monitor subkeys, you can run additional copies of the tool though in different folders (I already have ideas to improve this, but, only if people have a need for the tool).

  • Whilst it does not require UAC elevation, it will bug you for elevation every time it tries to import or export from the registry (It basically calls regedit.exe/reg.exe), so, I recommend that you run the program elevated... It does this several times and it will become very annoying.

  • No guarantees - It gets the "Works on my PC" badge, and I have tested it across a few machines, but, this has not had code review and hours of testing... Start to finish in a few hours.

Even if you do not end up using it, I hope it is useful to someone out there!

Download Link

William Hilsum

Posted 2011-08-25T17:43:50.120

Reputation: 111 572

Nice! Are you keeping it closed-source? – Ram Rachum – 2011-08-26T09:05:29.083

@Ram Rachum - I don't really "do" open source (whole projects) much... If anyone has any questions/wants to see anything, I will be more than happy to provide sample code from it... or share code with friends over Dropbox.... If you have any suggestions or want any improvements, let me know. ... I am still quite a new programmer and have been trying to get my head around VCS systems... When I understand them, I may upload/start sharing! – William Hilsum – 2011-08-26T10:25:55.220

1@William; Open Source doesn't have to be fancy, just zip up the source and upload it alongside and it's open source! – Phoshi – 2011-08-26T12:50:36.193

@Phoshi - :/ good point... Maybe soon then! – William Hilsum – 2011-08-26T13:08:03.287

RegSync v1 will be in codeplex in future like open source ? my company needs audit source code before install any application or program in environments. – Kiquenet – 2012-04-04T11:56:36.323

@Kiquenet - Not any time soon... Not even really sure where it is at the moment :/ Well - no need to use it if you don't want, but, I ensure you that it is safe. – William Hilsum – 2012-04-04T13:08:50.287

5

it might be easier to run regedit.exe in silent mode with a registry file that contains the exact entries you want. You can set each computer to run it from a shared location so all you need to do is update the file and when the next scheduled run of regedit.exe runs on each computer, they get the new entries.

something like:

regedit.exe /S puttyentries.reg

In order to pull a registry key from one computer, you would use:

regedit.exe /E puttyentries.reg "registry_key"

There would probably be more elegant ways of automating the whole process using vbscript or autoit with remote read/write functions for the registry.

Here is an example with AutoIt that will sync every 30 minutes with a remote computer (caveat, I really haven't tested this):

While 1 ;loop indefinitely
    $i1 = 1 ;set initial counter
    While 1 ;loops through all sessions
        $keyname = RegEnumVal("\\REMOTECOMPUTER\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions", $i1) ;reads session names
        If @error <> 0 Then ExitLoop ;exits when no more sessions exist
        $i2 = 1 ;set initial counter
        While 1 ;loops through all value in key until done
            $valuename = RegEnumVal("\\REMOTECOMPUTER\HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions" & "\" & $keyname, $i2) ;read value name from remote machine
            If @error <> 0 Then ExitLoop ;errors and escapes when no more values to read
            $type = @extended ;sets registry value type
            $value = RegRead("HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Session" & "\" & $keyname, $valuename) ;read value
            RegWrite("HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Session" & "\" & $keyname, $valuename, $type, $value) ;write key value to local machine
            $i2 = $i2 + 1 ;increment by 1
        WEnd
        $i1 = $i1 + 1 ;increment by 1
    WEnd
    Sleep(1800000) ;sleep 30 min
WEnd

MaQleod

Posted 2011-08-25T17:43:50.120

Reputation: 12 560

I wouldn't want to edit a file manually. Can regedit also extract from the registry in silent-mode? – Ram Rachum – 2011-08-25T18:32:59.063

edited to add read option, I will see what I can write up for a more elegant scripted option – MaQleod – 2011-08-25T18:59:32.270

1This may be adequate for the guy who asked, but the this will not sync deletion of settings. So if you delete a putty setting on one host export, re-import on your section host, the deletion will not happen. When you export and re-import back on the host you deleted a configuration item, your deleted item would be restored. – Zoredache – 2011-08-25T19:46:59.577

ok, added an autoit example that will do the whole process on its own (or at least it should, I have not tested it, so please back up everything first). – MaQleod – 2011-08-25T20:02:02.997