Jump to content

How to change profile directory?


Recommended Posts

Dear Export,

I'm using Win2k3 unattended installation to change the profile directory to another partition (I use C for normal system files and D for profiles). Yes, I know how to do it in winnt.sif. But my problem is I use a new HDD, and I partition it into two partitions. The Windows installer only lets me do partitioning; there's no way to format ALL the partitions before I install it.

Therefore, if I instruct the installer to place the profile directory in to D (the second partition), and because I cannot format D, the installer will report an error and cannot continue.

Is there any way to achieve this?

Thanks in advance!

Lei

Link to comment
Share on other sites


You could use the attached script. It asks for the new folder for the userprofiles, copies the folder of default user and all users and sets the entry in the registry, so that new profiles will be generated in the new location. Already existing profiles aren't touched.

Save the following as profiles.vbs and run it

-------------------------------------------------------------------------------------------------

Set wshshell = CreateObject("WScript.Shell")

Set fs = CreateObject("Scripting.FileSystemObject")

value_user = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Profilelist\ProfilesDirectory"

dir_docs = wshshell.RegRead(value_user)

Do

answer = vbYes

resiltat1 = 0

resultat2 = 0

'Dialog zur Auswahl des Ordners für die Profile öffnen

userfolder = folderbrowse

'Falls Cancel gedrückt wurde, das Skript beenden

If ( userfolder = "" ) Then

WScript.Quit

End If

pos = Instr (userfolder,":")

If NOT ( pos = 2 ) Then

Msgbox userfolder & " is not a valid directory. Please choose another one!"

Else

Set userfolderO = fs.Getfolder(userfolder)

If ( userfolderO.Subfolders.count > 0 ) OR (userfolderO.files.count > 0 ) Then

answer = Msgbox (userfolder &" is not empty. Overwrite?", vbYesNo + vBQuestion)

If ( answer = vbYes) AND (len(userfolder) > 3) Then

On Error Resume Next

fs.Deletefolder(userfolder)

End If

End If

If NOT ( answer = vbNo ) Then

dir_docs = wshshell.ExpandEnvironmentStrings(dir_docs)

befehl ="xcopy /o/h/e/i/y/q """ & dir_docs & "\all users"" """ & userfolder & "\all users"""

kommando = "%COMSPEC% /C " & befehl

resultat1 = wshshell.Run ( kommando, 1, True )

befehl ="xcopy /o/h/e/i/y/q """ & dir_docs & "\default user"" """ & userfolder & "\default user"""

kommando = "%COMSPEC% /C " & befehl

resultat2 = wshshell.Run ( kommando, 1, True )

If ( resultat1 <> 0 ) OR ( resultat2 <> 0 ) Then

msgbox "Copy failed! Please choose another directory"

If (len(userfolder) = 3) Then

On Error Resume Next

fs.Deletefolder(userfolder & """\all users""")

On Error Resume Next

fs.Deletefolder(userfolder & """\default user""")

Else

fs.Deletefolder(userfolder)

End If

End If

End If

End If

loop while (resultat1 <> 0) OR (resultat2 <> 0) OR ( answer =vbNo ) OR ( NOT pos = 2)

wshshell.RegWrite value_user,userfolder

Function folderBrowse

On Error Resume Next

Set slapp = WScript.CreateObject("Shell.Application")

Set V = slapp.BrowseForFolder (0, "Choose the new folder for the userprofiles ( or press cancel, if you don't want to move it)", 0, &H11)

If err.number <> 0 Then

folderBrowse = "Error number " & err.number

err.clear

Exit Function

End If

folderBrowse = V.self.path

End Function

Link to comment
Share on other sites

You could use the attached script. It asks for the new folder for the userprofiles, copies the folder of default user and all users and sets the entry in the registry, so that new profiles will be generated in the new location. Already existing profiles aren't touched.

Hi Doc,

Thanks for your reply. Yes, change the profile location for all the users is the second best solution if my original problem cannot be fixed. As a matter of fact, I did this menually before I tried to use unattended install approach. Where can I find such a script? Ta.

Lei

Link to comment
Share on other sites

Hi Doc,

Thanks for your script. I tested on my machine, and it looks ok. However, by searching the registry, I found not all the paths containing "All Users" are modofied. Is it safe to use?

Thanks,

Lei

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