%userprofile% variable question

  • Thread starter Thread starter 3c273
  • Start date Start date
3

3c273

Hello,

How come if this works:
-----
C:\>cd %userprofile%

C:\Documents and Settings\MyUserName>
-----

But this doesn't:
 
3c273 said:
Hello,

How come if this works:

It doesn't work because '%userprofile%' contains spaces. Enclose
in double quotes and it will work.

This works because '%systemroot%' does not contain any spaces.
 
3c273 said:
Hello,

How come if this works:
-----
C:\>cd %userprofile%

C:\Documents and Settings\MyUserName>
-----

But this doesn't:

cd %UserProfile% works because the cd command is
perhaps the only command that does not require
surrounding double quotes, even when the argument contains
spaces. You can also type this:

cd /d %userprofile%

when the current folder is d:\data (for example).
 
Doh! Thanks, I should have known that.
Louis

Phil Robyn said:
3c273 said:
Hello,

How come if this works:

It doesn't work because '%userprofile%' contains spaces. Enclose
in double quotes and it will work.

This works because '%systemroot%' does not contain any spaces.
 

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

Back
Top