Jump to content

Batch-file variable (win xp pro)


Recommended Posts

Hello,

How can I pick currently logged-in-user and use that as variable in my batch file?

I wanted to copy some files into c:\my documents\user X\some folder but the problem in path is that "user X".

Is there easy way to "read" that and use variable for it?

MMainio

Link to comment
Share on other sites


In Windows XP at least, you have the following variables:

%Userprofile% = "X:\Documents And Settings\Username".. if you have windows installed on C and the user name is Cow, then it'll return "C:\Documents And Settings\Cow"

%Username%="Username".. would just return "Cow" (I think this is the one you want)

These assume you have WinXP though.. I don't use other systems, so I can't help you otherwise. :)

Link to comment
Share on other sites

Following on from DarkPhoenix's post;

If you open a console (DOS) window and type "set" you will see a list of all the variables and their current values.

To use these in your batch file enclose them in "% %" symbols as you can see in DarkPhoenix's examples.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...