![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to set system's environment variable permanently How to add a Windows envirenment var permanently with PowerShell? The PowerShell Cookbook by Lee Holmes says this: $oldPersonalPath = [Environment]::GetEnvironmentVariable("PATH", "USER") $oldPersonalPath += ";d:\tools" [Environment]::SetEnvironmentVariable("Path", $oldPersonalPath, "User") however, when i do [Environment]::GetEnvironmentVariable("Path", "User") nothing is returned. Piping it to get-member returns the error: Get- Member : No object has been specified to get-member. I can do the following but it's just per session. $env ath = $env ath + ";C:\Users\xah\PowerShell scripts\"A quick search in this group doesn't seems to find answer. Thanks. Xah ∑ http://xahlee.org/ ☄ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to set system's environment variable permanently Read this article and especially note the caveat regarding restarting PowerShell. http://www.microsoft.com/technet/scr...pstip1214.mspx - Larry Xah Lee wrote: Quote: > How to add a Windows envirenment var permanently with PowerShell? > > The PowerShell Cookbook by Lee Holmes says this: > > $oldPersonalPath = [Environment]::GetEnvironmentVariable("PATH", > "USER") > $oldPersonalPath += ";d:\tools" > [Environment]::SetEnvironmentVariable("Path", $oldPersonalPath, > "User") > > however, when i do > > [Environment]::GetEnvironmentVariable("Path", "User") > > nothing is returned. Piping it to get-member returns the error: Get- > Member : No object has been specified to get-member. > > I can do the following but it's just per session. > > $env ath = $env ath + ";C:\Users\xah\PowerShell scripts\"> > A quick search in this group doesn't seems to find answer. > > Thanks. > > Xah > ∑ http://xahlee.org/ > > ☄ |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to set system's environment variable permanently To set it PERMANENTLY you use SetEnvironmentVariable, but to have it take effect NOW you need to use the Env: drive. Write yourself a little script that does both... -- Joel Xah Lee wrote: Quote: > How to add a Windows envirenment var permanently with PowerShell? > > The PowerShell Cookbook by Lee Holmes says this: > > $oldPersonalPath = [Environment]::GetEnvironmentVariable("PATH", > "USER") > $oldPersonalPath += ";d:\tools" > [Environment]::SetEnvironmentVariable("Path", $oldPersonalPath, > "User") > > however, when i do > > [Environment]::GetEnvironmentVariable("Path", "User") > > nothing is returned. Piping it to get-member returns the error: Get- > Member : No object has been specified to get-member. > > I can do the following but it's just per session. > > $env ath = $env ath + ";C:\Users\xah\PowerShell scripts\"> > A quick search in this group doesn't seems to find answer. > > Thanks. > > Xah > ∑ http://xahlee.org/ > > ☄ |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how to set system's environment variable permanently Larry__Weiss wrote: Quote: > Read this article and especially note the caveat regarding restarting PowerShell. > Thanks. Quote: Quote: > > [Environment]::GetEnvironmentVariable("Path", "User") > > nothing is returned. var of User category on my machine. I now try: [Environment]::GetEnvironmentVariable("Path", "system") but that's a error. Apparantly the name is not “system”. What should i put for the second param? It's not clear to me where i'd find this info. Am still grobing Windows system and docs... Xah ∑ http://xahlee.org/ ☄ |
My System Specs![]() |
| | #5 (permalink) |
| | Re: how to set system's environment variable permanently Read the error message in its entirety. Doesn't it tell you what the valid values are for that second argument? Were you able to get to the text of this article? http://www.microsoft.com/technet/scr...pstip1214.mspx - Larry Xah Lee wrote: Quote: Quote: Quote: >>> [Environment]::GetEnvironmentVariable("Path", "User") >>> nothing is returned. > var of User category on my machine. > I now try: > [Environment]::GetEnvironmentVariable("Path", "system") > but that's a error. Apparantly the name is not “system”. What should i > put for the second param? It's not clear to me where i'd find this > info. Am still grobing Windows system and docs... > > Larry__Weiss wrote: Quote: >> Read this article and especially note the caveat regarding restarting PowerShell. >> http://www.microsoft.com/technet/scr...pstip1214.mspx >> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: how to set system's environment variable permanently Xah wrote: Quote: Quote: > > I now try: > > [Environment]::GetEnvironmentVariable("Path", "system") > > but that's a error. Apparantly the name is not “system”.. What should i > > put for the second param? It's not clear to me where i'd find this > > info. Am still grobing Windows system and docs... Quote: > Read the error message in its entirety. Doesn't it tell you what the valid > values are for that second argument? Quote: > Were you able to get to the text of this article?http://www.microsoft.com/technet/scr.../pstips/dec07/... Xah ∑ http://xahlee.org/ ☄ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| environment variable not seen | Software | |||
| Path Environment Variable - Vista 64-bit | Vista General | |||
| PATHEXT environment variable and PS1 scripts | PowerShell | |||
| how to set environment variable where name is not a-z nor A-Z | PowerShell | |||
| how to set environment variable where name is not a-z nor A-Z | PowerShell | |||