Sign in to follow this  
Followers 0
BigDaddyO

Automating User Profiles Copy to command

5 posts in this topic

So, I have been working most of today trying to figure out how I can create a new user and then copy a current profile into that account.

I have found a COM example from a 2006 post here on how to create a new account but I havn't found anything that I would consider reliable for copying a profile to the new account. I don't think I can use a copy command because the profile I want to copy has had most of it's special folders redirected to alternate locations.

Any assistance would be greatly appreciated.

Thanks,

Mike


Share this post


Link to post
Share on other sites



http://www.microsoft.com/downloads/details...;displaylang=en

Overview

A Microsoft Windows user profile describes the Windows configuration for a specific user, including the environment and preference settings. The user profile also contains configuration options specific to the user, such as installed programs, desktop icons, and color options. This profile is built from Group Policy settings and from permitted, saved changes that a user makes to customize the desktop.

Administrators can use the CopyProfile tool to copy a profile from one user to another using a command line and also create default user profiles (see KB article 305709). This tool removes the dependency on the graphical interface and allows the administrator to copy profiles using scripts.

So, I have been working most of today trying to figure out how I can create a new user and then copy a current profile into that account.

I have found a COM example from a 2006 post here on how to create a new account but I havn't found anything that I would consider reliable for copying a profile to the new account. I don't think I can use a copy command because the profile I want to copy has had most of it's special folders redirected to alternate locations.

Any assistance would be greatly appreciated.

Thanks,

Mike

Share this post


Link to post
Share on other sites

thank you, thank you, thank you,

:)

I have spent half the day looking for something like this.

Mike


Share this post


Link to post
Share on other sites

You can use this code to create the new profile:

Func _ValidUserPass($username, $domain, $password)
    Local $valid = True
    RunAs($username, $domain, $password, 1, @ComSpec & " /c  echo test", @SystemDir, @SW_Hide)
    If @error Then $valid = False
    Return $valid
EndFunc

I don't think I can use a copy command because the profile I want to copy has had most of it's special folders redirected to alternate locations.

If I don't mistaken all the information is recorder at the userprofile/ntuser.dat hive. You can use the script above to create the new profile and then copy %SystemDrive%\Documents and Settings\OldUserProfile\NtUser.dat into the new profile. Or you can cheat by looking at the regkey HKLM_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList. Inside this key you going to find a lot of keys like "S-1-5-21-1957994488-1364589140-515967899-1130" profile SID account. Find the key for the old profile and the key for the new profile, assign the same value of ProfileImagePath from the old profile to the new profile. Restart the computer, no matter which account your login both of them are pointing to the same location.

Note: The only way to copy NtUser.dat from one profile to another is by rebooting the system and login with the administrator account or any other account with administrator right. Don't login with the accounts that you are trying to copy, you don't want ntuser.dat get loaded into the registry.


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If you have trouble reboot a second time.

Anytime I deal with NTUSER.DAT I have consistently had XP continue to lock the file until I rebooted a second time.

And no I did not login after rebooting :)

But maybe that's been changed in SP3 or was related to Group Policies and being in a domain.

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
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
Sign in to follow this  
Followers 0