1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

mkdir for each user

Discussion in 'DOS/Other' started by angusn, Jul 11, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. angusn

    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.
     
  2. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    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
     
  3. StumpedTechy

    StumpedTechy

    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
     
  4. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    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=\
     
  5. StumpedTechy

    StumpedTechy

    Joined:
    Jul 7, 2004
    Messages:
    7,235
  6. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    Like I said, the %USERNAME% or %USERPROFILE% variables are probably a better choice. ;)
     
  7. StumpedTechy

    StumpedTechy

    Joined:
    Jul 7, 2004
    Messages:
    7,235
    Not in my environment! :p :D
     
  8. Sponsor

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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/482224

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice