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?

  • Relevant: [In Windows Explorer, why can we create a folder or file with the percent (%) symbol, if the percent symbol is used for existing variables?](https://superuser.com/q/1096208) – DavidPostill Sep 08 '16 at 17:00

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^%
Ƭᴇcʜιᴇ007
  • 111,883
  • 19
  • 201
  • 268
0

I was able to mkdir with

mkdir "%test%"

and then navigate to it with

cd "%test%"

Also works with rename

J E Carter II
  • 376
  • 2
  • 6