profiles dir

B

Bertoldino

hi all :)
and sorry for my wobbly english... ;)

i have one problem and two ways i'd like to solve it... but I'm not able to
do what i thought, lol :)

in a .cmd file i need to change/set the volume to the one in wich i set the
"documents and settings" directory.
notice that i used unattended.sif to set it in different volumes , not "C"
....

i know i can retrieve %userprofile% variable

but if e.g. I have "r:\docs_and_sets\james"

and i need to retrieve the "r:\docs_and_sets" value (wothout the %username%)
, what variable i have to look for?

or

how can i know that the right volume is "R:" ?

i don't know how to do the string operations or how to retrieve the
variables with the correct value :)

OSes: win2000, XP, (Vista)

thanx! :)
 
P

Pegasus \(MVP\)

Bertoldino said:
hi all :)
and sorry for my wobbly english... ;)

i have one problem and two ways i'd like to solve it... but I'm not able
to
do what i thought, lol :)

in a .cmd file i need to change/set the volume to the one in wich i set
the
"documents and settings" directory.
notice that i used unattended.sif to set it in different volumes , not "C"
...

i know i can retrieve %userprofile% variable

but if e.g. I have "r:\docs_and_sets\james"

and i need to retrieve the "r:\docs_and_sets" value (wothout the
%username%)
, what variable i have to look for?

or

how can i know that the right volume is "R:" ?

i don't know how to do the string operations or how to retrieve the
variables with the correct value :)

OSes: win2000, XP, (Vista)

thanx! :)

You can extract the drive letter like so:
@echo off
echo Drive Letter = %UserProfile:~0,2%

and the folder name like so:
@echo off
call echo Profile folder = %UserProfile:%Username%=%

(provided that %UserName% is set as expected)
 
B

Bertoldino

Pegasus said:
You can extract the drive letter like so:
@echo off
echo Drive Letter = %UserProfile:~0,2%


perfect! this works!
and the folder name like so:
@echo off
call echo Profile folder = %UserProfile:%Username%=%

(provided that %UserName% is set as expected)

this doesn't seem to work :(

but THANKS for the first info!!
 
P

Pegasus \(MVP\)

Bertoldino said:
perfect! this works!


this doesn't seem to work :(

but THANKS for the first info!!

As I said - it depends on the value of %Username%. There
are other solutions but they are more involved. If the drive
letter solution is sufficient then you should use it.
 
B

Bertoldino

Pegasus said:
As I said - it depends on the value of %Username%. There
are other solutions but they are more involved. If the drive
letter solution is sufficient then you should use it.

can you explain me how the formula have to work in your intentions and in
which way we have to expect %username% is set?

is %userprofile:%username% a string subtraction?
 
P

Pegasus \(MVP\)

Bertoldino said:
can you explain me how the formula have to work in your intentions and in
which way we have to expect %username% is set?

is %userprofile:%username% a string subtraction?

No, it is a string substitution. Consider these commands:

set name=Bertoldino
echo %name:blush:=a% (yields "Bertoldina")
echo %name:ino=% (yields "Bertold")

My second batch file attempted to remove the user name from
the "%UserProfile%" variable. This will only work if the user
name is contained %UserProfile%, which is not necessarily
true.

A further degree of complexity arises when the substitution
string is in itself a variable. With a bit of black magic (that
is undocumented and unexplainable) the problem can be
resolved with the "call" statement.
 
B

Bertoldino

Pegasus said:
My second batch file attempted to remove the user name from
the "%UserProfile%" variable. This will only work if the user
name is contained %UserProfile%, which is not necessarily
true.

A further degree of complexity arises when the substitution
string is in itself a variable. With a bit of black magic (that
is undocumented and unexplainable) the problem can be
resolved with the "call" statement.

yeah!
that's the magic!
1) it works
2) i understand!

thanks, great!

....your blog/website? :)
 
P

Pegasus \(MVP\)

Bertoldino said:
yeah!
that's the magic!
1) it works
2) i understand!

thanks, great!

...your blog/website? :)

Thanks for the feedback. Sorry, no web site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top