Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

New 2.0 behavior regarding the PATH environment variable

15 views
Skip to first unread message

Chuck Heatherly

unread,
Nov 25, 2009, 3:47:48 PM11/25/09
to
PowerShell 2.0 RTM appears to be prepending its system path to the PATH environment
variable, but it is using a literal macro variable instead of expanding it.

This is the value of my PATH from the System Variables section in Control Panel:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

This is the value from a DOS Command Prompt:

C:\Windows\System32>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

This is from a PowerShell prompt on a Windows 7 system:

C:\> $env:path
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Wind
ows\System32\WindowsPowerShell\v1.0\

Note that all the other path strings are already expanded, except the first one that
PowerShell appears to be prepending.

This behavior, which was not in PowerShell 2.0 CTP3, is causing a problem for an in-house
tool in my company, which we can probably work around, but my question is, why is
PowerShell not expanding that variable before inserting it into the PATH? I think other
apps using the value of PATH would expect all the variables to be expanded already and not
have to do it again.

Chuck

Bob Landau

unread,
Nov 29, 2009, 1:42:01 PM11/29/09
to
Chuck this is a known bug luckily it doesn't affect most usages.
Unfortunately your application got hurt by this.

To Fix this you'll need to modify the registry which comes with all the
usual warning about your computer not booting or causing the next IceAge if
not done correctly.

Under HKLM\Software\Microsoft\Windows\CurrentVersion

you'll find a key called "App Paths"

There will be an entry for Powershell under this key. The type of this key
should be REG_EXPAND_SZ but unfortuately is REG_SZ so the expandable variable
%SystemRoot% is not processed.

bob

"Chuck Heatherly" wrote:

> .
>

0 new messages