Build a user's profile directory on creation in batch
Posted
by
Moses
on Super User
See other posts from Super User
or by Moses
Published on 2013-10-21T21:05:11Z
Indexed on
2013/10/21
21:56 UTC
Read the original article
Hit count: 270
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?
© Super User or respective owner