User Tools

Site Tools


pathvariable
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


pathvariable [2013/01/28 04:29] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== Path Variable ======
 +
 +Changing the actual environment variables can be done by using the env: namespace / drive info. For example this code will update the path environment variable
 +<code>$env:Path '' "SomeRandomPath";</code>
 +
 +There are ways to make environment settings permanent but if you are only using them from PowerShell, it's probably a lot better to use your profile to initiate the settings. On startup, powershell will run any .ps1 files it finds in the Windows PowerShell directory under my documents. Typically you have a profile.ps1 file already there. The path on my computer is
 +<code>c:\Users\JaredPar\Documents\WindowsPowerShell\profile.ps1</code>
 +
 +If you need to modify PATH environment variable temporarily, some time during PowerShell session, you can do it this way:
 +<code>$env:Path '' $env:Path + ";C:\Program Files\GnuWin32\bin"</code>
 +
 +Or even shorter:
 +<code>$env:Path +'' ";C:\Program Files\GnuWin32\bin"</code>
 +
 +From the PowerShell prompt:
 +<code>setx PATH "$env:path;\the\directory\to\add" -m</code>
 +
 +you should then see the text:
 +<code>SUCCESS: Specified value was saved.</code>
 +
 +<strong>restart your session</strong> and the variable will be available. ''setx'' can also be used to set arbitrary variables type ''setx /?'' at the prompt for documentation.
 +
 +Before messing with your path in this way, make sure that you save a copy of your existing path by doing''$env:path &gt;&gt; a.out'' in a PowerShell prompt
 +
 +-- Main.FredPettis - 2012-08-03
  
pathvariable.txt · Last modified: 2013/01/28 04:29 by 127.0.0.1