Topic: HOWTO Reinstall Windows XP preserving personal data using DP BASE - pa
HOWTO: Reinstall Windows XP preserving user data - parallel installation without a mess
Situation:
you have to reinstall Windows XP on a hard disk already containing a previous Windows XP and you can't backup your personal data because:
-you haven't partitioned the disk as C: for Windows and programs and D: for all personal data
-your previous Windows XP is corrupted and unable to boot
-don't want to write a bunch of backup DVDs and don't have an external USB HDD
NOTE: I've applied the process 10-20 times on different systems without any problem - nevertheless backing up your most critical personal data before the reinstallation is highly advised - I cannot take any responsibility if you mess up something or loose any of your data
What can you do:
-you can do a Repair Install - if you ever tried this you know that this sometimes just messes things up
-repartition or reformat your drive - you will get a clean Windows XP system but loose all your personal data
-leave the filesystem intact (aka parallel installation) - but this way you will get a multiboot setup, the new system goes under \WINDOWS.0, and there will be All Users.WINDOWS and Default User.WINDOWS folders under Documents and Settings, and your Program Files folder will be a mess
OR
-modified parallel installation: boot with BartPE, UBCD4WIN or a Linux Live CD with NTFS write support, delete \WINDOWS, \Program Files and rename \Documents and Settings to e.g. \Archive and after this preparation you launch your Windows XP Setup CD and choose Leave Filesystem Intact instead of partitioning&formatting - the setup process will do a clean install and leave your files unharmed on the disk. I'll show you how to do this in an unattended way.
The unattended way:
1. you can use nLite to modify your setup source and apply your favourite tweaks (http://www.nliteos.com/) (OPTIONAL)
2. after nLite but before the ISO creation slipstream drivers to your source with DriverPacks BASE (http://driverpacks.net/) This is a necessary step (and above that useful too - I always slipstream drivers to my source with Driverpacks so I don't have to hunt for drivers after the install) because we will take advantage of DriverPacks method 2 tweak. If you don't want to slipstream drivers I suggest you run DriverPacks BASE and slipstream the CPU drivers only - it takes on a few Kb of space in your source.
3. after DriverPacks BASE finished the slipstreaming process it will replace the original SETUP.EXE (which is called during the WinPE Phase of the setup process) with its own Fake SETUP.EXE. The DriverPacks Fake Setup calls the DriverPacks PreSetup.cmd. PreSetup unpacks the drivers from the CD to the hard disk and then it calls the original SETUP.EXE which then proceeds with the normal XP setup. We will modify this PreSetup.cmd with our batch commands taking advantage of that it gets called at the most appropiate moment of the setup process: the start of the WinPE stage which is between the text mode setup and the Gui Phase. So we integrate the following lines at the start of the PreSetup.cmd (you can find it in the I386 folder of the source)
IF NOT EXIST "%SYSTEMDRIVE%\Program Files" GOTO PRESETUP
CD %SYSTEMDRIVE%\
RD /Q /S "%SYSTEMDRIVE%\Program Files"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\All Users"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\Default User"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\LocalService"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\NetworkService"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\All Users.WINDOWS"
RD /Q /S "%SYSTEMDRIVE%\Documents and Settings\Default User.WINDOWS"
:RANDOMIZE
SET BACKUPDIR=Archive.%RANDOM%
IF EXIST %SYSTEMDRIVE%\%BACKUPDIR% GOTO RANDOMIZE
RENAME "%SYSTEMDRIVE%\Documents and Settings" %BACKUPDIR%
MKDIR "%SYSTEMDRIVE%\Documents and Settings\All Users"
MKDIR "%SYSTEMDRIVE%\Documents and Settings\Default User"
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" /v "AllUsersProfile" /d "All Users" /f
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" /v "DefaultUserProfile" /d "Default User" /f
REM FIXME <please see Issues section below> SET ALLUSERSPROFILE%="%SYSTEMDRIVE%\Documents and Settings\All Users"
:PRESETUP
...
<and here comes the contents of the original PreSetup.cmd>
...
What these script does is first it checks for the existence of "C:\Program Files" if this exists it assumes that a previous Windows installation is on the hard disk so it cleans up the Documents and Settings folder and renames it to Archive.<somerandomnumber>. After that we create the new empty Documents and Settings directory with All Users and Default User in it then we set the registry and the environment to point to these folders. When the setup process continues it won't have knowledge about the previous system installed on the same disk and this way we will get a fresh new installed system with our personal files backed up in the C:\Archive.<somerandomnumber> from where we can copy back our files to wherever we want them to be. We create a random folder for the backup in case there would already be an Archive folder in C:\.
4. Before creating our Setup CD ISO you also need to alter the contents of the I386/WinNT.sif file. You need to set the TargetPath variable under the [Unattended] section if it isn't already there like this:
[Unattended]
TargetPath="\WINDOWS"
This is necessary because if you don't set this variable the installation will take place under "\WINDOWS.0" folder if there's already a \WINDOWS directory on the partition from the previous system.
5. After that you can create your ISO from the source, burn it and pop it in for a nice Windows XP installation without losing your precious personal data on the partition.
Usage:
1. Boot from the Setup CD.
2. When Text Mode lists your partitions to choose for the new Windows install, choose the one where your old XP is already installed.
3. Select Keep the filesystem intact option.
4. Setup will ask you if it should delete the previous Windows installation, answer yes to that (L key).
5. Setup deletes your old \WINDOWS directory and create a new one for the new system.
6. After the reboot, our modded Presetup.cmd gets called which backs up the previous Documents and Settings and creates a new empty one.
7. The setup process continues further as normally would.
Issues:
Only one minor issue remained - after the setup process finishes I always end up with sharedaccess.ini placed inside C:\Documents and Settings\All Users.WINDOWS\Application Data\Microsoft\Network\Connections\Pbk instead of the normal C:\Documents and Settings\All Users\... place.
I believe this happens because ALLUSERSPROFILE is set to \Documents and Settings\All Users.WINDOWS by the setup process if you have a Documents and Settings folder already on the %SYSTEMDRIVE%. Unfortunately the SET command from my script (now REMmed out in the code) doesn't help in redefining this environment variable permanently because in WinPE it won't change ALLUSERSPROFILE globally - when PreSetup.cmd finishes it returns to All Users.WINDOWS. Anybody know a way to change it permanently?
Any feedback welcomed!
Last edited by mdjake (2009-01-16 08:21:50)