cmd - Accessing Folder with Environment Variable Name

Smartis

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?

Ƭᴇcʜιᴇ007

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^%

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Remove a folder with the same name as an environment variable

How to get current folder name in lowercase as variable in cmd?

How to put JOB_NAME excluding folder into an environment variable in Jenkins?

Accessing the name of a variable/argument

How to navigate to MySQL prompt using cmd without setting environment variable or without navigating MySQL service folder in Windows

Docker Environment variable not working in CMD

Environment variables and variable name

Accessing $_POST using a variable name

Set permanent environment variable for a folder

Accessing conda environment variable from python

Accessing nested array with variable variable name

Windows CMD - Rename files based on folder name

Using cmd compact with folder name patterns

Cmd findstr if folder name matches regex

How to know upper folder name via cmd

CMD batch escaping environment variable in params

pypfop 0.2.0 and environment variable FOP_CMD

Take cmd line parameter and echo it if it is an environment variable

Folder name in path variable is repeated

Folder name with Parentheses in bash variable

Copying a folder name to a variable in batch

Ansible variable name `environment` is reserved?

Postman get the environment name as a variable

Unsetting environment variable with an empty name

R - accessing variable "name" inside a function

Accessing a class name that is stored in the Jquery variable

Accessing an object variable with # and space in its name in an array

Python: name folder and file with variable name

BAT if exist %environment variable folder% (System folders)