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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

%userprofile% variable

Reply to Message Icon

Original Message
Name: kross
Date: March 21, 2007 at 11:39:16 Pacific
Subject: %userprofile% variable
OS: xp home
CPU/Ram: old
Model/Manufacturer: 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?


Report Offensive Message For Removal


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

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



Report Offensive Follow Up For Removal

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

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


Report Offensive Follow Up For Removal

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

Change to WHICH directory?


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

M2



Report Offensive Follow Up For Removal

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

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


Report Offensive Follow Up For Removal

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

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


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

M2



Report Offensive Follow Up For Removal


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

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


Report Offensive Follow Up For Removal

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

@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



Report Offensive Follow Up For Removal

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

Perfect man!!!! Thanks!


Report Offensive Follow Up For Removal






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








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software