Posts

Improvements on: Backup and restore Windows 7 activation status (Offline activation after reinstall)



This post is an elaboration of the necessary steps in order to backup Windows 7 activation status before doing a clean re-install and then restoring it back, with the command lines instructions to do the tricky parts. Note that a valid key is required; this does not support piracy, it just saves you from increasing the activation count on a valid key just because you are doing a clean install.
  1. Copy and save or backup the following activation-related files to external storage medium such as USB flash drive or portable hard disk drive: C:\Windows\ServiceProfiles\NetWorkService\
    AppData\Roaming\Microsoft\SoftwareProtectionPlatform\Tokens.dat
    and,C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms
    Note: For 64-bit (x64) OS, C:\Windows\SysWOW64\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms have to be backed up too.
  2. Retrieve and record the product key used to install and activate the current Windows 7 or Windows Server 2008 R2.
  3. Reinstall Windows 7 or Windows Server 2008 R2. When installation wizard prompts for a product key for activation, leave it blank (do not enter anything).
  4. In the newly installed Windows operating system, stop the Software Protection Service in Services.msc or with the following command (run in elevated command prompt): 
net stop sppsvc
  1. Navigate to the following folder:C:\Windows\System32\spp\tokens\pkeyconfig\
  2. Take ownership and give user full control permissions (alternatively add grant full control right click menu item) to pkeyconfig.xrm-ms file.
cd C:\Windows\System32\spp\tokens\pkeyconfig\
    takeown /f *
      cacls * /g users:f
        1. Delete the original default pkeyconfig.xrm-ms file, and replace with the backup copy.
        2. Note: In 64-bit (x64) operating system, also perform the above  actions in C:\Windows\SysWOW64\spp\tokens\pkeyconfig\ folder.
        cd C:\Windows\SysWOW64\spp\tokens\pkeyconfig\

        takeown /f *
          cacls * /g users:f
          1. Navigate to the following folder:C:\Windows\ServiceProfiles\NetWorkService\
            AppData\Roaming\Microsoft\SoftwareProtectionPlatform\ 
          2. Take ownership and give user full control permissions (alternatively add grant full control right click menu item) to tokens.dat file.
          cd C:\Windows\ServiceProfiles\NetWorkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\
          takeown /f *.dat
            cacls *.dat /g users:f
               

              1. Delete the original default tokens.dat file, and replace with the backup copy.
              2. Restart the Software Protection Service in Services.msc or with the following command (run in elevated command prompt):
               net start sppsvc
              1. Register the product key for Windows 7 or Windows Server 2008 R2 with the following command (run in elevated command prompt): slmgr.vbs -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
                Replace xxxxx-xxxxx-xxxxx-xxxxx-xxxxx with the actual product key.
              2. Windows will activated instantly, off-line. To check activation status, uses of of the following commands: 
                • slmgr.vbs -dlv
                • slmgr.vbs -dli
                • slmgr.vbs -ato

              Install any version of Windows 7 from a single DVD

              *note* This idea should work, but it doesn't quite. Suggestions welcome!

              Any windows 7 x64 DVD has all x64 editions on it, and a single file which tells the disk which version to install. Remove that file and the installer will helpfully ask you which version you want! Note: the same is true of a x86 (32bit) disk, for all 32 bit editions of Win7.

              The file is ei.cfg and while there are tools to edit the ISO for you, wouldn't you rather know that nothing else has been done to the disk? A simple solution I tried, but which did not work is to edit the ISO with a hex editor that supports large (>2GB) files and Unicode (since filenames are stored as unicode). The hexeditor HxD works great for this. You can legally download the ISO direct from Microsoft's partner here (or see here for a list of versions).

              What does work is writing the ISO file to a USB flash drive using Rufus, and then deleting the EI.CFG file.

              For those curious on how to edit the ISO directly (which as I said, doesn't work), read on:

              In theory, all you need to do is change the file name on the disk. Search for ei.cfg (as a unicode string) and the first instance found is the file name (at offset 9D430). Change the 65 at that offset to a 64 and now it's di.cfg. Save and you are done! If you want to check, open the ISO file with a viewer (such as 7zip) and verify that the ei.cfg is now called di.cfg (it's in the \source directory). This clearly changes the name of the file. If you write the ISO to a USB flash drive, the result is as intended; the dialog box opens during install to ask what version you want. But if you burn it to DVD, the result is that halfway into the install Windows fails and claims it needs a driver to read the DVD. So somehow this hack corrupts the UDF image in a way that windows cannot recover from. I also tried searching for later references to ei.cfg, presuming these would be in the code that loads the file; there was only one additional reference in unicode, which I changed to di; the install disk now works ok, but does not load up the menu where you can change the edition. So there must be non-unicode instances of the file on the disk as well.



              Note that this has nothing to do with bypassing activation. This just allows you to use a single disk to install any version you want. You still need a valid product code for the version you installed. 


              Built in PDF viewer in Chrome much better than in Firefox

              Adobe Acrobat has a new security hole found every day (OK, slight exaggeration), and is slow and bloated. The appeal of a light-weight in-browser PDF viewer is undeniable. Now both Chrome and Firefox offer this option. But the Firefox viewer produces blurry text, and I do not recommend for anything but quick on-screen previewing.


              The Firefox PDF viewer does not support "sub-pixel" font rendering which means that any text smaller than about 16 points looks blurry and is hard to read. If your only goal is to print the PDF after checking that you downloaded the right one, it's certainly good enough, but if you want to save a tree, you'll soon get tired of reading such blurry text, unless you like to read each page zoomed in so that only 1/2 of it fits on-screen at a time.

              I'd provide a screen shot but "sub-pixel" rendering means splitting each pixel into its red/green/blue components and turning on more of them or less depending on the width and locating of the stroke that passes through that pixel. So it only looks good if you know what order the colors are arranged on your LCD (RGB, GBR, etc) and if you guess wrong it actually looks much worse. So take it from me.

              Or, if you want to see yourself, here's the best step-by-step instructions I've found:

              http://www.groovypost.com/howto/enable-firefox-pdf-reader/

              After following those steps I still needed to go into the browser preferences and switch the content handler for PDFs from external to "Firefox". Perhaps that is all you really need to do, I don't know.

              Chrome supports sub-pixel rendering, and I find I can read an 8x11 page full-screen on my 24inch LCD with no problem. The same is true with Acrobat, of course, but Adobe's product is just too unsafe to use. The only time I've ever gotten anything like a virus was from a hole in Acrobat (that has happened twice to me, in over 20 years of computer use, meanwhile obsessive virus scanning has NEVER turned up a single virus on any file I've downloaded from the Internet).

              Updating Paypal IPN PHP 4.1 scripts to use HTTP 1.1: SOLVED!

              Paypal has made a change in their system which required some changes to my long-working PHP code, version 4.1. Here's the official notice:


              Action Required before February 1, 2013
              Merchants need to update their IPN and/or PDT scripts to use HTTP 1.1, and include the "Host: www.paypal.com" and "Connection: close" HTTP headers in the IPN and PDT scripts.

              Their full-sized example script is now for PHP 5.x so it wasn't easy to see how to make the changes to my older 4.1 script. Yes, they give you a four line snippet showing the new code added, but without enough context to make it work. There's several other forum posts out there suggesting that I'm not the only one confused. None of them have the complete working code posted, though. So here's the correct solution (tested and working as of today):

               // post back to PayPal system to validate
              // OLD working version
              //$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
              //$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
              //$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

              // new working version:
              $header .="POST /cgi-bin/webscr HTTP/1.1\r\n";
              $header .="Host: www.paypal.com\r\n";
              $header .="Content-Type: application/x-www-form-urlencoded\r\n";
              $header .="Connection: close\r\n";
              $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";


              // new working version changes finished, old code resumes:
              $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);



              One thing that tripped me up: the header needs to end with the double end-line, so the order matters at least in that one way. I'm not sure the rest of the order really matters, buy hey, this works!

              Note: this code is part of a larger package that delivers software (or anything zipped) via email to people who send you money with PayPal (or Amazon). Check it out: http://hcidesign.com/linux/

              EVGA GTX 260 - the best driver choice under WinXP?

              I recently upgraded to a used GTX 260 (EVGA, type SC; model 896-P3-1257-AR to be specific), for the purposes of playing Minecraft, etc. more smoothly. This has been pretty successful - the GTX 260 gets about 2x the frame rate of my old ATI X800 XL, and is only slightly more noisy (because the fan is larger and runs faster). 

              But the upgrade was not without problems (since solved, see below). The moment I put the card in I started having problems with hibernating WinXP which had never occurred with the old video card.  About 1/4th of the time hibernation would appear to finish, and the screen would go blank, but the machine would not actually switch off. Worse, upon rebooting, the computer would act like it had hung, and discard the hibernation file, instead proceeding to a regular, full boot. It was like my computer was crashing about once a day. 

              Suspecting a driver incompatibility, I tried several different ones:

              301.42 - hibernate problems
              296.10 - hibernate problems
              285.58 - machine somewhat unstable
              280.26 - machine very unstable 

              275.33 - hibernate OK, but machine is now unstable (most often hanging hard while watching video).

              Other recommendations from around the net:

              EVGA forum.

              I contacted EVGA support, and they gave me a bunch of fairly basic tech support suggestions that I had little hope would fix the problem, and indeed they didn't. Then they suggested I RMA the card, which I did. Problem solved! The card is now completely stable with out any hibernate problems under the 301.42 driver (I didn't test any others). It only cost me about $5 to RMA the card, because of shipping it back to them. Turn around was super fast - they sent the replacement card out the same day it got to them, and it was in my hands the next day (note, however, both EVGA and I are in S. California).

              So to conclude: hardware problem.

              Update, again:  after about 1 month I had another crash on entering hibernate. That's a lot less than before I sent the card back, but still suggests that the problem isn't actually fixed, as my machine never had this problem with the old ATI card. Not sure what to conclude now.

              How much faster have CPUs gotten in the last 15 years?

              If you got into the PC business in the 80s or 90s, you can probably remember how each new CPU from Intel was a pretty big performance boost. In those days, a new CPU could offer two kinds of performance advances: clock speed increases, and instructions that took fewer clock cycles to complete. By the time the 486 came out, most instructions took just 1 cycle to complete (down from 4-6), and we had gone from 8mhz to 100+mhz in just a decade. With the first Pentium, Intel introduced the ability to complete instructions in parallel, which meant that a single clock cycle could sometimes result in 2 instructions executed (or more properly, completed, since at this point we had execution pipelines). Later CPUs had even more pipelines, but the gains were diminishing. Clock speeds were still increasing, however. This did not mean that CPUs were getting faster though. Famously, Intel actually took a big step back in performance per clock cycle from the Pentium 3 to the Pentium 4, in order to push into the 4 Ghz range.  In modern times, performance per clock cycle has taken a bit of a back seat to putting more cores into your CPU - great if your software supports multithreading, but even after almost a decade of this approach, a lot of software does not.

              So, how do CPUs of the last 15 years compare on single-threaded computation? Not many people have the CPU collection to answer this question, myself included. Tom's CPU charts is the closest I could find, but in 2006 they switched to using a multi-threaded mp3 benchmark, so the best they can offer is the years 1994-2004. To extend this I replicated their benchmark (single threaded) on my desktop, which is shown at the bottom of the following list.

              Tom's cpu charts 2004 (seconds to encode a large MP3 file using LAME, so smaller is better):

              1994 Intel Pentium                      100mhz     4361
              1997 Intel Pentium MMX           233mhz     1926
              1999 Intel Pentium III                 600mhz       360
              2000 AMD Athlon thunderbird  1ghz             233
              2001 AMD Athlon XP 1500+   1.3ghz)         169
              2001 Intel Pentium 4                  1.8 ghz         162   
              2004 AMD Athlon 64 2800+    1.8ghz          119
              2003 AMD Athlon XP 2800+   2 ghz            105
              2004 Intel Pentium 4 570           3.8ghz            84
              2004 AMD Athlon 64 FX-55    2.6ghz            82
              2010 AMD Phenom II 255 X2  3.1ghz            46 (estimated)

              The most impressive gains happened in the 90s - 4300 seconds is a long time to encode an MP3 (even a long one). Since then, single threaded performance has gone up, but not so much. The difference between 82 seconds and 46 is almost half, but that's not such a huge change in how long you have to wait. We can see, however, a general trend that more is getting done per clock tick (excepting the P4, of course). 

              The weakness of this list, of course, is that there is no attempt to make sure that each of these CPUs is comparable in terms of cost to the user when they were introduced. But it does show that while raw Ghz hasn't gone up much in the last decade, compared to the 90s, single thread performance has still continued to rise somewhat faster than Ghz. 

              Radeon incompatibility with Dell LCDs (U2410)

              I recently upgraded my video card to an EVGA 260 GTX (SC), for reasons of performance and compatibility. My old video card (Radeon X800 XL) was reasonably quite, fast enough for non-gaming needs, and OK for watching flash video, but not great. Most annoying of all, it has an incompatibility with my Dell U2410 LCD, where it cannot wake the screen back up after it has been put into power saving mode by the screensaver. Apparently the video card sends a signal to the DVI port to see if there is a device there, and the DELL takes too long to respond so the ATI card stops sending a signal, and never discovers that anything is attached. I found I could get around this by opening a full-screen DOS prompt, which causes the ATI drivers to power up the DVI port whether it thinks there is a screen attached or not. I set up a hotkey to open and then close a fullscreen DOS window, thus bringing my display back to life, but what a pain! I don't think this was a problem with all Dell displays - I don't recall the same problem with my older 2408WFP.

              To be fair to ATI, this is an old card. But the drivers weren't that old; you'd think this was something that could have been fixed in software. The good news was that the upgrade to an Nvidia card fixed it. Plus, flash video no longer exhibits taring problems. You know, full screen video playback was a problem most software solved in the late 90s. Flash is such a dog - apparently it can only use hardware acceleration with fairly modern video cards - which the ATI card certainly isn't. But then every other video playback program I used was tare-free, so it certainly had the horsepower to do the job if given even half a chance.

              Email me

              Name

              Email *

              Message *