Recently Windows 7 on one of my laptops became unstable and I had to restore from a System Image. This worked.. sort of. After restoring I found that Microsoft Security Essentials had to be repaired, and the .NET Framework 4.0 seemed to be corrupt.
When running programs that require the .NET Framework I would get the above error: "
Please set registry key HKLM\Software\Microsoft\.NETFramework\InstallRoot to point to the .NET Framework install location"
This prohibits me from running many different programs including Visual Studio 11 Beta so this had to be fixed!
The obvious first step was to uninstall .NET Framework 4.0 and reinstall. This did not help.
Next was to manually edit the registry to try and provide the data requested in the error message. This was confusing because the key was present and contained the path to the framework directory in the Windows directory. It looked OK.
Next I tried the
.NET Framework Setup Verification Tool. This confirmed that the framework was not installed properly but, to be honest, I could not determine from the log file what was actually wrong.
The last resort is to do an in place install of Windows 7 - basically replace all the system files. Through my Technet subscription I have access to an ISO of Win 7 SP1 so I grabbed this [BTW, Microsoft, why can't you enable resuming on the Technet download servers?] and tried to make a bootable USB key by which to install Windows 7. If you have the Windows DVD media then this will be also be fine.
I usually use the
Windows 7 USB DVD Download Tool from Microsoft Store. But guess what? This required .NET 4.0 to be properly installed!
There is another product,
WinUSB Maker, which is popular but this also requires .NET4.
What to do?
Well, I found another tool which can do the trick and does not require the .NET Framework:
NoviCorp WinToFlash. This can copy a Windows DVD to a USB drive and make the drive bootable. It can also format the drive if required.
The only thing is WinToFlash does not natively work with ISO files, so you will also need a Virtual DVD-ROM such as
VirtualCloneDrive.
The process is simple:
1. Mount the Windows ISO with VirtualCloneDrive
2. Run the WinToFlash wizard
3. Choose the VirtualCloneDrive drive (e.g. E:) as the Windows disk, and your USB drive as the target.
4. Allow WinToFlash to format the drive if it asks.
5. That's it.
Now to reinstall Windows 7, just insert the USB key and AutoRun should start the installer. If it doesn't just open the drive in Windows Explorer and run Setup.exe. Follow the instructions until you choose Upgrade or Custom. Choose Upgrade to reinstall.
Do not choose custom unless you want to delete all your existing files and programs!
Note: you can only reinstall the same version of Windows, so you can't upgrade to Pro from Ultimate, and so on.
As for .NET,
Hope that helps. Any questions - reach out in the comments.
Update: 31-May-2012
The above
did not fix the .NET Framework corruption for me. I messed around some more but ended up having to do a fresh install of Windows 7. Then everything worked great.