Difference between revisions of "Windows Path Enviroment"

From Ever changing code
Jump to navigation Jump to search
(Created page with "== Display environment variables == SET | more PATH == Set the system PATH == setx path "%path%;c:\directoryPath"")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Display environment variables ==
== CMD - Display environment variables ==
SET | more
<syntaxhighlightjs lang="powershell">
PATH
set | more
PATH
</syntaxhighlightjs>
 
== PowerShell ==
<syntaxhighlightjs lang="powershell">
gci env:PATH
ls Env:PATH
$Env:PATH="$env:PATH;c:\temp"
$Env:path += ";c:\temp"
</syntaxhighlightjs>
 
== Set the system PATH ==
== Set the system PATH ==
setx path "%path%;c:\directoryPath"
<syntaxhighlightjs lang="powershell">
setx path "%path%;c:\directoryPath"
</syntaxhighlightjs>
 
== set vs setx ==
*<code>set</code> sets an environment variable until the end of the current command prompt session, or until you set the variable to a different value
*<code>setx</code> sets an environment variable in both the current command shell and all command shells that you create after running the command. It does not affect other command shells that are already running at the time you run the command.

Latest revision as of 17:35, 3 May 2019

CMD - Display environment variables

<syntaxhighlightjs lang="powershell"> set | more PATH </syntaxhighlightjs>

PowerShell

<syntaxhighlightjs lang="powershell"> gci env:PATH ls Env:PATH $Env:PATH="$env:PATH;c:\temp" $Env:path += ";c:\temp" </syntaxhighlightjs>

Set the system PATH

<syntaxhighlightjs lang="powershell"> setx path "%path%;c:\directoryPath" </syntaxhighlightjs>

set vs setx

  • set sets an environment variable until the end of the current command prompt session, or until you set the variable to a different value
  • setx sets an environment variable in both the current command shell and all command shells that you create after running the command. It does not affect other command shells that are already running at the time you run the command.