{"id":172,"date":"2009-07-22T17:25:55","date_gmt":"2009-07-22T23:25:55","guid":{"rendered":"http:\/\/www.goodjobsucking.com\/?p=172"},"modified":"2009-07-22T17:25:55","modified_gmt":"2009-07-22T23:25:55","slug":"restoring-selected-keys-from-the-registry","status":"publish","type":"post","link":"http:\/\/www.goodjobsucking.com\/?p=172","title":{"rendered":"Restoring Selected Keys from the Registry"},"content":{"rendered":"<p>As I hope everybody does, I have a backup system in place that ensures that I have copies of all critical files, including the system registry.\u00a0 A combination of Volume Shadow Copy and BackupPC ensure that I&#8217;ll have ample copies of the registry available, but the registry itself makes recovery a less-than-straightforward process.<\/p>\n<p>For a bare metal restore, the process is actually not too bad.\u00a0 To be specific, you can pretty much just copy over the registry files with backups (which is pretty much every file in %systemroot%\\system32\\config) then rebooting before doing anything else.<\/p>\n<p>More specifically, you want these files:<\/p>\n<pre>security, software, system, default, sam<\/pre>\n<p>It gets a little weirder from there if you need registry elements from the user hives and security hives, which is conveniently spread out into places like &#8220;Documents and Settings\\NetworkService\\NTUSER.DAT&#8221;, &#8220;Documents and Settings\\LocalService\\NTUSER.DAT&#8221; and helpfully named things like &#8220;UsrClass.dat&#8221; spread all over creation.<\/p>\n<p>It wasn&#8217;t really my purpose to delineate all these things, so I&#8217;ll move on:\u00a0 instead, my purpose was to point out that what, after losing a drive and reinstalling the operating system, you decide that you don&#8217;t <em>want<\/em> to inherit all the cruft that was lurking in your &#8220;old&#8221; registry, but instead would like to pull over just a few select keys?<\/p>\n<p>On the plus side, there&#8217;s a way to do it.\u00a0 On the minus side, doing so is about as convoluted as the registry itself.<\/p>\n<p>First, the keys you&#8217;re looking for are most likely to be housed in the file &#8220;software&#8221; or &#8220;system,&#8221; depending on whether you want some keys describing installed software or hardware, respectively &#8212; so restore these files somewhere.\u00a0 The location doesn&#8217;t matter, as long as you don&#8217;t put them on top of their current locations.<\/p>\n<p>Second, fire up the registry editor (&#8220;regedit&#8221; or &#8220;regedt32&#8221;) which will give you a view of your current registry.\u00a0 Click on HKEY_LOCAL_MACHINE, which will then make the menu option <em>File-&gt;Load Hive<\/em> available.<\/p>\n<p>Go ahead and pick the &#8220;software&#8221; file you restored, and you&#8217;re immediately prompted for &#8220;Key Name.&#8221;\u00a0 This is the key name to mount the hive under, so pick something that&#8217;s <em>not<\/em> a hive already in use.\u00a0 (In other words, do NOT pick &#8220;software&#8221; or &#8220;hardware&#8221; and so on.)\u00a0 It&#8217;s handy, if possible, to pick something absolutely guaranteed not to be in use as a key or value anywhere in the registry, but really anything will do.<\/p>\n<p>Now you can browse the hierarchy of the registry from the file you loaded.\u00a0 Note that none of these keys are really &#8220;in&#8221; the registry, but now you can get to them, to select what you need out of the original registry &#8212; in my case, it&#8217;s almost universally nit picking serial numbers from software I installed long ago and I have an easier time finding the CD than I do where the original serial numbers went.\u00a0 Once you&#8217;ve selected the key, <em>File-&gt;Export<\/em> will allow you to extract it in text form.<\/p>\n<p>Unfortunately, registry exports store the absolute path of whatever you&#8217;re exporting, so you&#8217;ll have to edit the file to get it back in.\u00a0 N.B.:\u00a0 Regedit is notoriously picky about the format of this file, and it will refuse to import a file that isn&#8217;t perfect, right down to white space, so you don&#8217;t want to edit it with anything that&#8217;s going to touch anything but the text (yes, I&#8217;m looking at you, TextPad.)\u00a0 I recommend Notepad with word wrap OFF.<\/p>\n<p>The exported registry file will be littered with references like:<\/p>\n<p>[HKEY_LOCAL_MACHINE\\MY_HIVE_KEY\\GoodJobSucking]<\/p>\n<p>Your job, of course, is to change every single &#8220;MY_HIVE_KEY&#8221; to &#8220;SOFTWARE&#8221; (or whatever hive you&#8217;re trying to get the key back into, while leaving everything else alone.\u00a0 If you were clever about the hive name you selected, this can be a global search-and-replace.<\/p>\n<p>Save the file, then use <em>File-&gt;Import<\/em> to bring the key(s) back in to the actual registry.\u00a0 When you&#8217;re done with this procedure, click on your hive with the crazy name, and select <em>File-&gt;Unload Hive<\/em> to be rid of it.\u00a0 There&#8217;s no &#8220;save&#8221; in the registry editor, so you&#8217;re done at this point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I hope everybody does, I have a backup system in place that ensures that I have copies of all critical files, including the system registry.\u00a0 A combination of Volume Shadow Copy and BackupPC ensure that I&#8217;ll have ample copies of the registry available, but the registry itself makes recovery \u2026 <a class=\"continue-reading-link\" href=\"http:\/\/www.goodjobsucking.com\/?p=172\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[36,91,92],"_links":{"self":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/172"}],"collection":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=172"}],"version-history":[{"count":2,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/172\/revisions"}],"predecessor-version":[{"id":174,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/172\/revisions\/174"}],"wp:attachment":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}