I am trying to prepopulate a user's home directory before they log in for the first time. I would like to do this programmically. Right now, I can create a the folder, but when a user logs in, it creates a different one with the domain added to the end. Here is what so far.
@echo off
IF EXIST C:\USERS\%1 GOTO COMPLETE
GOTO FIRSTLOGON
:FIRSTLOGON
:: Create user folder on C:\
mkdir "C:\USERS\%1"
:: copy folder structure from template to new user folder
mkdir "c:\Users\%1\Desktop"
mkdir "c:\Users\%1\Documents"
mkdir "c:\Users\%1\Downloads"
mkdir "c:\Users\%1\Music"
mkdir "c:\Users\%1\Pictures"
:: Set rights on new folder
::: Remove inheritance, grant owner everything and admin everything
icacls "C:\USERS\%1" /inheritance:r /grant DOMAIN\%1:(OI)(CI)F
icacls "C:\USERS\%1" /grant %computername%\Administrator:(OI)(CI)F
GOTO END
:COMPLETE
echo Folder creation complete
:END
However, the folder wont be the user's home directory. I am guessing that I will need to add a registry key with the user's GUID to HKLM > SOFTWARE > Microsoft > Windows NT > CurrentVersion > ProfileList, but unsure how to get the GUID from the username, and if I need to do anything else.
Note: I don't want do change the user's home directory for every computer, just the one that they are logging in.