Build a user's profile directory on creation in batch
- by Moses
I have a batch script that I use when I set up new Windows 7 PCs that creates a user based on a variable, creates a folder on their desktop, then shares it:
@echo off
SET /p unitnumber="Enter unit number: "
net user unit%unitnumber% password /add /expire:never
MD "C:/Users/unit%unitnumber%/Desktop/Accounting #%unitnumber%"
runas /user:administrator "net share "Accounting#%unitnumber%"="C:/Users/unit%unitnumber%/Desktop/Accounting#%unitnumber""
I discovered that the share that is created is overwritten when the newly created user first logs on, because Windows creates builds their profile directory at that time.
Is there any way to initiate a build of a user's profile directory in the batch file just after creating the it? The only thing that looks useful is the /homedir:pathname switch for the net user command, but I believe that option assumes the directory already exists.
Other than that web research hasn't been fruitful.
I'd be to use whatever to get this done as long as I can incorporate/launch it from the batch.
Any suggestions?