3

I'm just curious about this:

It's possible to create a Folder, in Windows Explorer, with the same Name as an Environment Variable (like %ProgramData%).

The same procedure in CMD.exe with mkdir prevents this and if i try to access this folder, i always get re-directed to the Environment Variable.

But is there any known way to access this kind of Folder with the command-line?

Are there any escape parameters for this, to prevent resolving the variable?

2 Answers2

1

For accessing the directory (via cd), you could use the console's character replacement (aka wildcards), and replace one of (or both) the percent signs with a question mark. e.g.:

  • cd ?ProgramData%
  • cd %ProgramData?
  • cd ?ProgramData?

Alternatively, and for use with other commands like rename, md and such, you can escape the percentage with a caret (^). e.g:

  • md ^%ProgramData^%
0

I was able to mkdir with

mkdir "%test%"

and then navigate to it with

cd "%test%"

Also works with rename