Jump to content

SOLVED: Installing Windows XP preserving user data


Recommended Posts

HOWTO: Reinstall Windows XP preserving user data

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 - 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

-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 right at the start of the Gui Phase of the setup process with its own dummy SETUP.EXE which calls DriverPacks' PreSetup.cmd first (this will unpack the drivers from the CD to the hard disk) and then the original SETUP.EXE next to go on with the 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: after the text mode and in the beginning of 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"

RENAME "%SYSTEMDRIVE%\Documents and Settings" "Archive.%RANDOM%"

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

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. This happens right at the beginning of the Gui Stage so 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. Reboots into Gui Mode.

7. At the beginning of the Gui Mode our modded Presetup.cmd gets called which backs up the previous Documents and Settings and creates a new empty one.

8. The setup process continues further as normal.

Issues:

1. It is advised that you move back your personal files to the appropriate place after the installation finishes and remove the C:\Archive.<randomnumber> folder after that. If not there may be a small risk of an interference between the Archive folders next time you try to reinstall XP preserving your data.

2. 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 don't know why it gets placed there (what other registry key should I modify) but I haven't found that this would break anything and I think I can safely copy it to the appropriate location after the setup process finished.

Any feedback welcomed!

Edited by mdjake
Link to comment
Share on other sites


hey there,

I posed your prob to a friend of mine and he replied:

"tell him it's the hivesys.inf and hivedef.inf - also has them paths in it - so you need to apply at start of setup and at end of setup (t13) and once more at Logon and post logon" and "oh and 1 more problem he'll encounter - the System ID (SID) will stop some apps from working with a fresh install with re-pointed paths. SID is locked - so if he used a SID changing tool - he may bypass that issue - but I don't know how he's go about getting it done"

hope it helps!

if it all works, pls let us know so we can borrow your work! :D

Link to comment
Share on other sites

No, this is not I mean. I mean I'd like to MOVE Documents and Settings somewhere else and preferably wipe out Program Files. I'd like to preserve user data like images, videos, pics, docs - I don't care about settings and installed programs. Have you ever installed Vista keeping the filesystem intact? It moves your old data to a folder C:\OLD (if I recall it correctly, it was half a year ago) where you can later access it from your fresh new installed OS.

Link to comment
Share on other sites

I've made some progress in this matter. Instead of using a DetachedProgram script to relocate the previous Windows installation's folders (namely Program Files, Documents and Setting) I've found that Driverpacks (which I use in my unattended setup CD) provide an easy way to run commands easily in the early stages of the setup process. Basically what Driverpacks' method 2 does the following: it replaces Setup CD's SETUP.EXE with a dummy exe which calls i386/Presetup.cmd and after that runs the original backupped SETUP.EXE (SetupORG.EXE).

So I made my modifications to this Presetup.cmd which runs just at the beginning of the GUI stage:

1. I boot from the modded Windows XP Setup CD.

2. I choose my partition which contains a previous Windows XP installation and choose Leave filesystem intact (no changes)

3. Setup tells me that a previous Windows installation is already on that partition, do I want to overwrite it? (you need to specify TargetPath = /WINDOWS in WINNT.SIF otherwise new Windows will install to WINDOWS.0)

4. I say yes, so Setup deletes the old \WINDOWS folder and copies the setup files to the partition. Textmode finished.

5. Now by using Driverpacks method 2 I add some lines to the start of the i386/presetup.cmd which removes the previous Windows installation's Program Files directory (I don't want interfence and most of the programs need reinstallation anyway) and relocates the whole Documents and Settings folder to C:\BAK. This way I will have the entire Documents and Settings folder under C:\BAK containing all the personal data from the previous Windows installation. The installation can continue in the new C:\Documents and Settings folder not interfering with old data - I copy back my personal data after the whole installation finishes from C:\BAK\Documents and Settings.

I have one last problem to solve: when I get control at the start of the GUI phase the setup process already creates two empty folders: C:\Documents and Settings\All Users and C:\Documents and Settings\Default User. If there was a previous Windows installed on the partition these two folders will be automatically named C:\Documents and Settings\All Users.WINDOWS and C:\Documents and Settings\Default User.WINDOWS (because the All Users and Default User folders are already there from the previous installation). Also %ALLUSERSPROFILE% is set to C:\Documents and Settings\All Users.WINDOWS. How could I relocate these two folders after successfully backing up Docs and Settings? I don't want All Users.WINDOWS folder.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...