If only you could control names of directories, where Microsoft installs Windows, Data and Program Files.
If you could, you would be able to install multiple instances of operating system on the same drive. So. let’s do it anyway. To do that you need two parallel installs of you favorite operating system on the same computer. For now it has to be on 2 different drives. You need this so you can manipulate locked files and directories of one install, while booting into the other one.
Disclaimer
This article applies to any Microsoft operating system, and uses the most complicated Windows 7 64-bit as an example. This method was also tested and works brilliantly on Windows 2008 R2 Server.
This is a highly advanced and technical matter. To follow topics discussed here, reader is expected to be well versed in File and Registry manipulations.
All mistakes you make, are your mistakes. Proceed with caution. Backup profusely. Method described here provided “as-is”, without any guarantees or assurances.
Scope
You just installed a fresh crisp instance of Windows 7 (or XP, or W2K8 Server). You can only login into the instance, but you didn’t instal any applications, or made any customizations.
This article demonstrates how to rename all Windows System directories according to a plan. The steps described here were tested multiple times on Windows 7 x64, Windows Server 2008, Windows Server 2008 R2 x64, and now on Windows 8.
[2013-02-24 SU 22:24]
This technique was tested twice with Windows 8 x64 Pro. A smashing success was achieved, when I was able to catch a brand new install clean after a second restart, boot into a parallel Win7 instance and update all directories in registry. When I tried to do it after Windows 8 complete the install, I could not make Start Tiles to work properly. Everything else worked ok.
We are planing to perform these renames, moves and deletes:
Old Location or Name | Win7 Location or Name | Win 2008 R2 Names |
---|---|---|
Documents and Settings | Delete | Delete |
PerfLogs | Delete | Delete |
Program Files | 1W7PROG | 1R2PROG |
Program Files (x86) | 1W7PRO86 | 1R2PRO86 |
ProgramData | 1W7DATA\ProgramData | 1R2DATA\ProgramData |
Users | 1W7DATA | 1R2DATA |
Windows | 1W7WIN | 1R2WIN |
Rename and Move Directories
Let’s start with the simplest task of actually renaming and moving the folders. Do not get discouraged, if your changes don’t take hold. You also need to delete files desktop.ini inside the folders that you are renaming (except for the Windows folder).
The best practice is to use only 8 positions in system folder names. First character for the year of install (0 for 2010, 1 for 2011). Second and third positions are used to identify operating system (XP for Windows XP, W7 for Windows 7, E7 for Win 7 Enterprise, K3 and K8 for Server 2003 and 2008, R2 for Server 2008 R2). Remaining 5 positions are used for the name itself.
Directories – Before | Directories – After |
---|---|
A New Faster Method is Available |
---|
Since I wrote this article back in December of 2010, I developed a completely new method of bulk updating the Registry. This new method consists of (01) loading a Registry hive into current Registry, (02) saving the Registry security to a text file, (03) taking ownership and granting full access for Administrators, (04) updating Registry with a third party tool, (05) restoring Registry security back to its original state and (06) unloading the hive. |
This article has been completely re-written for this new fast method. Details on this methodology you can find here. |
Registry Manipulations
Now we need to manipulate registry files in our target install to update all hard-coded paths to point to new locations.
We will have to repeat this step for 6 registry files. So, you need to understand, what are we up against here. Instead of this being a simple task of search and replace (like in Word document), our task is complicated by these factors:
(1) Registry Record Locks – you need a second parallel install to manipulate the Registry files freely.
(2) Registry Security. You can’t easily write your updates back to Registry due to severe Registry security.
(3) Registry Format. Some values are recorded in HEX and can’t be easily picked up by simple search and replace. You need a serious and smart Registry tool to do the job right.
Prerequisites:
(1) In the example bellow, we placed Microsoft utility subInACL into C:\T directory;
(2) External registry hives always loaded using name QQQQ;
(3) You need to download a third-party utility “Registry Toolkit” (see link at the bottom);
(4) Use elevated security Command Prompt in all examples.
Before you start backup entire “C:\1R2WIN\System32\config” directory.
`
(1) Update SOFTWARE Registry File
This section is already re-written and describes new, fast and automated way of doing the updates in SOFTWARE hive.
(01) Load SOFTWARE into Registry and name it QQQQ.
(02) Save QQQQ Registry security to a file with this command (Note: use elevated security CMD):
C:\T\subInACL /noverbose /output=C:\T\QQ-Software.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
In 16 to 28 seconds you will get a 75-100MB text file “qq-software.txt” that contains all information about loaded registry hive security.
(03A) Take ownership of the entire QQQQ hive for Administrators (27 seconds on W2K8 R2):
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
and (03B) Give full rights for Administrators for all branches of QQQQ ( 40 seconds on W2K8 R2):
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
Do not get discouraged, if you get an error message here. Just repeat steps 3A and 3B till you get no errors.
Search | Replace with in Win 7 |
Replace with in W2K8 R2 |
Win 7 Replacement Count |
W2K8 R2 Replacement Count |
---|---|---|---|---|
C:\Windows | C:\1W7WIN | C:\1R2WIN | about 4,000 | more than 2,450 |
C:\Program Files (x86) | C:\1W7PRO86 | C:\1R2PRO86 | 112 | 69 |
C:\Program Files | C:\1W7PROG | C:\1R2PROG | 61 | 39 |
%\Program Files | %\1W7PROG | %\1R2PROG | 4 | 0 |
C:\ProgramData | C:\1W7DATA\ProgramData | C:\1R2DATA\ProgramData | 35 | 7 |
%\ProgramData | %\1W7DATA\ProgramData | %\1R2DATA\ProgramData | 1 | 1 |
C:\Users | C:\1W7DATA | C:\1R2DATA | 36 | 10 |
%\Users | %\1W7DATA | %\1R2DATA | 3 | 3 |
(04) Only now we are ready to perform bulk updates of Registry values. We are renaming old C:\Windows values into a new C:\1W7WIN and several others according to a table above. I use a free and amazing third-party Registry Toolkit for Windows x64 Ver. 4.1 to do the mass updates.
Table above to the right is showing replacements that we need to do in a loaded QQQQ hive and corresponding replacement count that you might expect to perform. Make sure you are doing your replacement in order shown in the table.
After you done with replacements search QQQQ manually to see, if any old values are still there after the replacement. In Windows 7 there are a 3 keys that were left behind. We need to do a little manual clean up to replace old values that were left behind.
Using you regular REGEDIT navigate to HKEY_LOCAL_MACHINE\QQQQ\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink and fix old C:\Windows values for keys:
Segoe Media Center
Segoe Media Center Light
Segoe Media Center Semibold
In W2K8 R2 there is not need for manual replacements. but in any case double and triple check at this point. Using regular RegEdit search QQQQ for any instances of C:\Wind, or C:\Prog, or C:\User and pay special attention to
HKEY_LOCAL_MACHINE\QQQQ\Microsoft\Windows NT\CurrentVersion\ProfileList:
While doing this one more time for a new install, I just caught an instance that somehow was not replaced either by me or by utility. By checking and fixing the problem now, I saved many painful minutes of troubleshooting and fixing down the road. Image above demonstrates, why we have to search and replace not only C:\Users, but also %\Users.
.
(05) Restore QQQQ Registry security to its original state:
C:\T\subInACL /playfile C:\T\QQ-Software.txt
This commands restores 140,225 registry security settings and takes 47 seconds to complete.
Just a sanity check, make absolutely sure that correct new values are recorded in these important keys located at:
HKEY_LOCAL_MACHINE\QQQQ\Microsoft\Windows\CurrentVersion
CommonFilesDir
CommonFilesDir (x86)
CommonW6432Dir
ProgramFilesDir
ProgramFilesDir (x86)
(06) Unload QQQQ hive from your Registry.
All this huge amount of work can be done in minutes instead of 2 hours using old semi-manual method.
Please note that in Windows 8 the replacement count is significantly higher, and you do not need to make manual adjustments.
`
Search | Replace with | Win 7 Replacement Count |
W2K8 R2 Replacement Count |
---|---|---|---|
C:\Windows | C:\1W7WIN | 364 | 307 |
C:\Program Files (x86) | C:\1W7PRO86 | 0 | 0 |
C:\Program Files | C:\1W7PROG | 0 | 0 |
%\Program Files | %\1W7PROG | 0 | 0 |
C:\ProgramData | C:\1W7DATA\ProgramData | 6 | 5 |
%\ProgramData | %\1W7DATA\ProgramData | 0 | 0 |
C:\Users | C:\1W7DATA | 0 | 0 |
%\Users | %\1W7DATA | 0 | 0 |
(2) Update SYSTEM Registry file
(01) Load SYSTEM into Registry and name it QQQQ.
(02) Save QQQQ Registry security to a file with this command:
C:\T\subInACL /noverbose /output=C:\T\QQ-System.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
In 3 seconds you will get a 13MB text file “qq-system.txt” that contains all information about loaded registry hive.
(03A) Take ownership of the entire QQQQ hive for Administators:
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
and (03B) Give full rights for Administrators for all branches of QQQQ:
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
(04) Replace values according to the table (on the right) in the order shown
Manual tweaks for SYSTEM could include these exceptions
Value C:\Users in key Users at HKEY_LOCAL_MACHINE\QQQQ\ControlSet001\services\LanmanServer\Shares and HKEY_LOCAL_MACHINE\QQQQ\ControlSet002\services\LanmanServer\Shares.
Very last “sanity check” before proceeding to a next step – search QQQQ hive for any instances of C:\W C:\P or C:\U.
(05) Restore QQQQ Registry secuirty to its original state:
C:\T\subInACL /playfile C:\T\QQ-System.txt
This commands restores 21,308 registry security settings and takes 12 seconds to complete.
(06) Unload QQQQ hive from your Registry.
All this huge amount of work can be done in minutes instead of 2 hours using old semi-manual method.
Only few more files to go.
`
Search | Replace with | Win 7 Replacement Count |
---|---|---|
C:\Windows | C:\1W7WIN | 195 |
C:\Program Files (x86) | C:\1W7PRO86 | 0 |
C:\Program Files | C:\1W7PROG | 10 |
%\Program Files | %\1W7PROG | 0 |
C:\ProgramData | C:\1W7DATA\\ProgramData | 6 |
%\ProgramData | %\1W7DATA\\ProgramData | 0 |
C:\Users | C:\1W7DATA | 0 |
%\Users | %\1W7DATA | 0 |
(3) Update DEFAULT Registry File
All 6 steps are exactly the same for a small DEFAULT file. No replacements in this hive are required in Windows Server 2008 R2.
Table to the right shows searches and replacements that I had to on Windows 7 Enterprise x64.
Here is a list of commands that you might need for this hive:
C:\T\subInACL /noverbose /output=C:\T\qq-default.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
==== Make Your Replacements Here ====
C:\T\subInACL /playfile C:\T\qq-default.txt
Only 3 more file to go.
`
Search | Replace with | Win 7 Replacement Count |
---|---|---|
C:\Windows | C:\1W7WIN | about 500 |
C:\Program Files (x86) | C:\1W7PRO86 | 0 |
C:\Program Files | C:\1W7PROG | 1 |
%\Program Files | %\1W7PROG | 0 |
C:\ProgramData | C:\1W7DATA\\ProgramData | 1 |
%\ProgramData | %\1W7DATA\\ProgramData | 0 |
C:\Users | C:\1W7DATA | 52 |
%\Users | %\1W7DATA | 0 |
(4) X:\1W7DATA\<You_User_Name>\NTUSER.DAT
Everything is exactly the same here and no manual updates are required. Here are the commands:
C:\T\subInACL /noverbose /output=C:\T\QQ-NTUSER.DAT.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
==== Make Your Replacements Here ====
C:\T\subInACL /playfile C:\T\QQ-NTUSER.DAT.txt
This is a very small file (0.5MB), and you should have minimal problems with updating REG file and merging it back to the registry.
Do not forget to unload hive. Only last 2 small files to update.
‘
Search | Replace with | Approximate Replacement Count |
---|---|---|
C:\Windows | C:\1W7WIN | 424 |
C:\Program Files (x86) | C:\1W7PRO86 | 0 |
C:\Program Files | C:\1W7PROG | 0 |
%\Program Files | %\1W7PROG | 0 |
C:\ProgramData | C:\1W7DATA\\ProgramData | 0 |
%\ProgramData | %\1W7DATA\\ProgramData | 0 |
C:\Users | C:\1W7DATA | 0 |
%\Users | %\1W7DATA | 0 |
(5) X:\1W7WIN\ServiceProfiles\LocalService\NTUSER.DAT
No replacements are required for this file for Windows Server 2008 R2.
C:\T\subInACL /noverbose /output=C:\T\QQ-LocalService.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
==== Make Your Replacements Here ====
Manual fixes are reguired here: NONE
C:\T\subInACL /playfile C:\T\QQ-LocalService.txt
(6) C:\1W7WIN\ServiceProfiles\NetworkService\NTUSER.DAT
Search | Replace with | Approximate Replacement Count |
---|---|---|
C:\Windows | C:\1W7WIN | 428 |
C:\Program Files (x86) | C:\1W7PRO86 | 0 |
C:\Program Files | C:\1W7PROG | 0 |
%\Program Files | %\1W7PROG | 0 |
C:\ProgramData | C:\1W7DATA\\ProgramData | 0 |
%\ProgramData | %\1W7DATA\\ProgramData | 0 |
C:\Users | C:\1W7DATA | 0 |
%\Users | %\1W7DATA | 0 |
No replacements are required for this file for Windows Server 2008 R2.
C:\T\subInACL /noverbose /output=C:\T\QQ-NetworkService.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /setowner=Administrators
C:\T\subInACL /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /grant=Administrators=F
==== Make Your Replacements Here ====
Manual fixes are reguired here: NONE
C:\T\subInACL /playfile C:\T\QQ-NetworkService.txt
We are done with Registry. All files, where references to old directory names existed are now updated. Almost…
Fix BCDEDIT boot configuration
This step is required for Vista, Windows 7/8 and Win 2008 Server systems. For Win XP and W2K3 edit boot.ini instead.
On this step you need to re-point boot database to a new windows directory (1W7WIN) that you just moved your Windows 7.
Run command prompt (cmd.exe) as administrator. Type BCDEDIT and press Enter. Note the identifier for Windows 7 instance in question. You need to change “path” and “systemroot” values. Type these two commands:
BCDEDIT /set {bb75c035-0289-11e0-82e7-b3c514d39e81} path “\1W7WIN\system32\winload.exe”
BCDEDIT /set {bb75c035-0289-11e0-82e7-b3c514d39e81} systemroot \1W7WIN
or if your new installation is still a default one:
BCDEDIT /set {default} path “\3W8WIN\system32\winload.exe”
BCDEDIT /set {default} systemroot \3W8WIN
Replace the {…} ID with your unique ID. Make sure you are getting a successful reply for each command. Run BCDEDIT again to inspect updates visually.
Let’s Boot Into Our New Instance
Moment of truth is here. Try to boot into your new 1W7WIN install.
It is working with no immediate error messages.
Now, when your new Windows 7 install with custom system directories is working, it is just matter of time to finish up some clean up.
First, check your %SystemDrive%. Make sure that Windows did not create and directories with old names. If it did, you miss some updates in Registry.
Second, Perform once again Registry search for C:\Win C:\Prog and C:\User to make sure none are exist.
If everything works and humming, your first order of business is to backup your creation. Get out into a parallel instance and run a backup script that will copy all 4 new system directories into a secure location, where you can use it once and again, whenever you need a fresh crispy install. Spend time now to save hours and agonizing days later! For a sample of a backup script see http://www.domainwebcenter.com/?p=1439, and scroll down to a section “Move/Copy Windows System Directories“.
Sources and Acknowledgments
Amazing Registry Toolkit – http://www.funduc.com/rtshareware.htm
Article that helped me to find Registry Toolkit (for advanced users only) – http://www.bbearren.com/set7free/set7free3.html).
A very desirable Robocopy.exe utility- http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx – that can move and copy large system folders from drive to drive without constant prompting for confirmation.
Microsoft Tool to Save and Restore Registry Security – SubInACL – can save registry security to a text file and then restore it back later.
I wrote a separate article (Save and Restore Registry Security) about this new to me feature.
Thanks a lot for both articles.
Currently I’m an XP guy, but soon I’ll have to move towards Win7. In the XP world, I have created my own install kits, so Windows will start in the “proper” folders. As the only constraint was that “Program Files” HAS to be in the windrive’s root, my setup looked something like that: “Program Files”=\Win51Px1, “Document and Settings”=\Win51Px1\_USERS, “Windows”=\Win51Px1\_WIN32, “Common Program Files”=\Win51Px1\_SHARE … This way, there is only one root folder for a complete windows installation. I also created epty, hidden, system, ro files named “Documents and Settings”, “Program Files”, etc. in the drive’s root, to catch stupid installers.
As now Win7’s installation is image based, and only \Users \ProgramData can be configured in the installation kit, the method you describe seems the only way to create a fully customized folder structure (that could then be converted to a setup disk). As I currently don’t have a system to experiment with, I’d like to ask you two questions:
1. Have you ever tried the “one root folder” configuration in Win7? If you did and it worked, any of the “special folders” has to stay as a root folder? If you didn’t try it, but you have a system to play with and some spare time, I would really appreciate if you could see if it works.
2. Have you ever used this method to move any of those folders (i.e. “Users”) to another drive? If you did, has it caused any issues with applying Microsoft patches and updates?
Thanks.
Thank you for your comments!
I thought that somewhere on the planet someone would need to change the rigid directory names like C:\Program Files and so on. I am glad that article found its audience.
My results: Success, with not one error! Windows 7 x64. Thanks for this great post!
Hours could be saved if MS deployment retained former… “flexibility”.
My other replies can be removed, just a note about reading Windows 7 (x64) registry from XP (x86): even the same version of subinacl (v 5.2.3790.1180) resulted in errors, e.g.: “Error displaying security descriptor using the Win32 security descriptor string format SDDL : 1336 The access control list (ACL) structure is invalid.”
My last post is not needed..
Your instructions indicate modifying with the same OS on another drive. Despite this, I tried modifying Windows 7 x64 from running Windows XP x86. Is this why with subinacl v 5.2.3790.1180 I get a these errors?
e.g.
> subInACL /noverbose /output=C:\T\QQ-NetworkService.txt /subkeyreg HKEY_LOCAL_MACHINE\QQQQ /display=sddl
NetworkService:
Last Failed: HKEY_LOCAL_MACHINE\QQQQ\Software\Microsoft\SystemCertificates\Root\ProtectedRoots – Error displaying security descriptor using the Win32 security descriptor string format SDDL : 1336 The access control list (ACL) structure is invalid.
(this happens in ntuser.dat too, others in software)
Thanks!
Thanks for this article, it’s awesome! Sometimes brute-force is elegant. ;)
Maybe there’s not more attention because there’s a little learning curve, but this is not hard and I’ve done similar.
With 2000 and XP, normal deployment allowed custom system directories (and side-by-side installs).
Directories like “Documents and Settings” and “Program Files”? Cumbersome to type and script around (even to look at), and junctions aren’t ideal.
In Microsoft style, they seem to have deleted a few lines of code and removed those features in the Vista/7 setup. But I won’t be waiting for someone’s 150kb patch…
It seems this method will work in XP (because subinacl and Registry Toolkit does) …unlike the WAIK (dism and imagex work fine in XP, MS just made it difficult to get the files).
I’ll report on my findings…
Keep posting stuff like this i really like it