Glam Prestige Journal

Bright entertainment trends with youth appeal.

I would like to initialize new user account on Windows 10 without login out from admin and login in again to user. Now I create new account with following command:

net user "username" "password" /add

Next I run some program with command that should load user profile:

C:> runas /profile /user:user program.exe

However it is not equivalent to the logging as this user. Environment and some folders structures are not prepared without actual logging in. Is there any way to do this?

2 Answers

The system creates a user profile the first time that a user logs on to a computer. At subsequent logons, the system loads the user's profile, and then other system components configure the user's environment according to the information in the profile.

Then you can't initiative user profile without logging in. Quoted from (v=vs.85)

It IS possible to do this via command line. Though, you'll need to use a system dll instead of plain cmd commands. I found the solution with the help of this answer from serverfault. Here is how to do it:

  1. Download the powerShell-Script from this GitHub site. This script is basically a PowerShell wrapper to use the functionality of userenv.dll.

  2. Save the script in C:\your\favorite\directory and rename user-profile.psm1 to user-profile.ps1 to easily make it run with PowerShell (*.psm1 is not configured to run in PowerShell by default).

  3. Start a PowerShell in elevated mode (as administrator) an navigate to C:\your\favorite\directory.

  4. Run the following two lines in PowerShell (the first line makes the function Create-NewProfile in user-profile.ps1 available, the second line does the actual work):

    . "C:\your\favorite\directory\user-profile.ps1"
    Create-NewProfile -Username testuser -Password start123

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy