Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Say I have a user environment variable named p and it's value is the path where I store my projects.

In Command Prompt you can use them to quickly access a particular directory from anywhere on the command line:

cd %p%

This doesn't work in Powershell, is there anyway to get the same functionality?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Environment variables have their own provider:

cd $env:p
share|improve this answer

addtional info: You can also set that environment variable for your session incase you need to change it for some reason during your session

$env:p = "C:\MyPath"

Or to set it globally if you need to update it

[Environment]::SetEnvironmentVariable("p", "C:\MyPath", "User")

This would create the user environment variable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.