Computing.Net > Forums > Programming > %userprofile% variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

%userprofile% variable

Reply to Message Icon

Name: kross
Date: March 21, 2007 at 11:39:16 Pacific
OS: xp home
CPU/Ram: old
Product: doesnt matter
Comment:

Anyone know a simple batch script that can list a directory of variable folders, then change to that variable? Example user names in documents and settings. The path to get into the user account folder you're logged into is %userprofile% is there anything like that for an account you arent logged into? if there isnt what would work to list and change to a variable dir?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 21, 2007 at 12:16:20 Pacific
Reply:

Not clear what you want to do. You can list the other accts with this:

::== uu.bat
@echo off
setLocal EnableDelayedExpansion

pushd "C:\Documents and Settings"
for /f "tokens=* delims= " %%a in ('dir /b/ad') do (
echo %%a
)
::==



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: kross
Date: March 21, 2007 at 12:23:09 Pacific
Reply:

Basically in a batch file go into documents and settings, list and change to the foldernames. Folder names are always different because they are user accounts. So just need to list the user account folders in the batch file and change to that directory


0

Response Number 3
Name: Mechanix2Go
Date: March 21, 2007 at 12:26:45 Pacific
Reply:

Change to WHICH directory?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: kross
Date: March 21, 2007 at 12:29:01 Pacific
Reply:

to a variable directory.. like a profile name like John.. but if im not logged in as john how to i get the batch file to read the folder name & put me into that directory


0

Response Number 5
Name: Mechanix2Go
Date: March 21, 2007 at 12:39:02 Pacific
Reply:

cd /d "C:\Documents and Settings\John"


=====================================
If at first you don't succeed, you're about average.

M2



0

Related Posts

See More



Response Number 6
Name: kross
Date: March 21, 2007 at 12:47:09 Pacific
Reply:

no i mean like have the batch file do it.. but the name john is the variable its always different. say you have 5 folders in docs and settings. folder names nancy john tommy and alpha.. in the batch file without actually typing in any of those names.. how would i get the script to list them, then change to those dir's one at a time.. see what im trying to actually do is delete a file in appdata but the username is always different.. but without the full path(like john & sally) i cant


0

Response Number 7
Name: Mechanix2Go
Date: March 21, 2007 at 12:56:27 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

pushd "C:\Documents and Settings"
for /f "tokens=* delims= " %%a in ('dir /b/ad') do (
pushd "%%a\Application Data"
echo now we're in:
cd
echo and can do the delete
popd
)
popd



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 8
Name: kross
Date: March 21, 2007 at 13:01:26 Pacific
Reply:

Perfect man!!!! Thanks!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: %userprofile% variable

enter variable in batch file www.computing.net/answers/programming/enter-variable-in-batch-file/14466.html

Batch programming, username changing www.computing.net/answers/programming/batch-programming-username-changing/19822.html

Batch - Get variable from text file www.computing.net/answers/programming/batch-get-variable-from-text-file/17052.html