Hey guys,
Can anyone tell me in Windows 7/Vista, how to find the name of the current user and where a certain file is located?
For example:
I need to know what the person's username is so I can find the C:\Users\(Name)
Also, I need to know where the file that is executing (as in my batch file) where it is on the computer.
Thanks in advance guys!
--Matt
Finding the directory name
Moderator: DosItHelp
-
- Posts: 82
- Joined: 24 Apr 2011 19:20
Re: Finding the directory name
To find the user
To find the location of the batch file
Code: Select all
@ECHO OFF
ECHO %USERNAME%
ECHO %USERPROFILE%
PAUSE
To find the location of the batch file
Code: Select all
@ECHO OFF
ECHO %~DP0
PAUSE
-
- Posts: 11
- Joined: 24 May 2011 13:20
Re: Finding the directory name
alleypuppy wrote:To find the userCode: Select all
@ECHO OFF
ECHO %USERNAME%
ECHO %USERPROFILE%
PAUSE
To find the location of the batch fileCode: Select all
@ECHO OFF
ECHO %~DP0
PAUSE
Okay so I get the first one. That make sense. But when I try the second one, it doesn't work.
I type in "echo %~DPO" but it just returns with %~DPO.
Any help?
And thanks for the initial help!
Re: Finding the directory name
'
~DPO: it doesn't work from the console, only if executed from script.
enter for /? for help on %0, %*, %~dp0...
~DPO: it doesn't work from the console, only if executed from script.
enter for /? for help on %0, %*, %~dp0...