mkdir for each user

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

angusn

Thread Starter
Joined
Oct 30, 2003
Messages
17
I want to run a batch file which will create a directory on the profile of the currently logged on user. Is this the correct syntax? It seems not to be correct:

mkdir "C:\Documents and Settings\%user%\CostManager"

Thanks in advance.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,429
Try %username% in that command.

This is from a SET command in a command prompt on my machine:

USERDOMAIN=MAIN
USERNAME=John Will
USERPROFILE=C:\Documents and Settings\John Will
 
Joined
Jul 7, 2004
Messages
7,235
Johnwill your not saying your setting your Username manually are you? Your just saying this is what SET shows right? Usernames should be an automatic variable and not something that is required to be set.

Technically you could do it a few ways -

mkdir "C:\Documents and Settings\%username%\CostManager"

OR

mkdir "%userprofile%\CostManager"

or you could use Homepath if their homepaths have not been modified as I believe that too defaults to C:\Documents and Settings\User
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,429
Yes, I included the actual command you need to use, it uses %USERNAME%, not %USER%, that was the mistake. I thought that was pretty clear in my post. :confused:

Of course, %USERPROFILE% has the complete path in it, and would be another good choice. :)

FWIW, here's what my HOMEPATH says, probably not what you meant, doesn't seem it would be all that useful.

HOMEPATH=\
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,429
Like I said, the %USERNAME% or %USERPROFILE% variables are probably a better choice. ;)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top