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.

I have a strange behavior with the environment variables at my Windows XP SP3.

When I logon as Administrator, the %SystemRoot% strings in PATH are substituted to C:\WINDOWS, the value of the variable 'SystemRoot' is C:\WINDOWS.

But when I logon as any non-administrative user, the %SystemRoot% literally remains in the PATH, although the variable 'SystemRoot' has the same value as with Administrator's account.

Running PowerShell as a normal user:

PS C:\Users\vic> $env:path (Enter)

%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Program Files\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static

Running PowerShell elevated (I right click, run as admin):

PS C:\Windows\system32> $env:path

C:\Windows\system32\WindowsPowerShell\v1.0\;C:\Program Files\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\ System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static

Env path in Windows:

C:\Program Files\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static

Why?

share|improve this question
    
What is the question / issue precisely? –  AthomSfere Oct 17 '13 at 14:12
    
He's asking why the expression of the $PATH variable is different (albeit slightly) when the shell is elevated. –  Colyn1337 Oct 17 '13 at 18:50
add comment

1 Answer

This behavior is because PowerShell is not referencing the %PATH% system environmental variable, but a different user environmental variable, specifically %HOMEPATH%.

In short, you see a different path based on which user you run PowerShell as, because the %HOMEPATH% variable for your users is different.

If you go to the properties of PowerShell (right click on the icon, select Properties from the context menu) and then click on the shortcut tab, you should see something like the screen shot below. The Start in: value is what you're seeing as your starting path (for you, C:\Users\vic or C:\Windows\system32). This is configurable, and you can set it to a static directory, like C:\, as well as using environmental variables.

enter image description here

share|improve this answer
add comment

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.