Powershell as Admin - Ignoring system path variable #19217

Closed
opened 2026-01-31 06:37:09 +00:00 by claunia · 9 comments
Owner

Originally created by @SteseDav on GitHub (Jan 16, 2023).

Windows Terminal version

1.15.3466.0

Windows build number

Version 10.0.22000.856

Other Software

No response

Steps to reproduce

Windows Powershell (elevated to admin) reads the PATH system variable and uses the items within correctly. (I have a custom scripts folder which I call all the time, so it's easier to just type the command)

With a Powershell tab in Terminal, running as admin, doesn't seem to do this by default,

Expected Behavior

I should be able to reference my powershell scripts directly without using the full path.

Actual Behavior

Powershell in Terminal cannot find the scripts, and gives a standard "unable to find" error.

Originally created by @SteseDav on GitHub (Jan 16, 2023). ### Windows Terminal version 1.15.3466.0 ### Windows build number Version 10.0.22000.856 ### Other Software _No response_ ### Steps to reproduce Windows Powershell (elevated to admin) reads the PATH system variable and uses the items within correctly. (I have a custom scripts folder which I call all the time, so it's easier to just type the command) With a Powershell tab in Terminal, running as admin, doesn't seem to do this by default, ### Expected Behavior I should be able to reference my powershell scripts directly without using the full path. ### Actual Behavior Powershell in Terminal cannot find the scripts, and gives a standard "unable to find" error.
claunia added the Needs-TriageIssue-BugNeeds-Author-FeedbackNo-Recent-Activity labels 2026-01-31 06:37:10 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jan 16, 2023):

What's the environment in each type of session (elevated vs unelevated)? I just wanna see if there's anything immediately obvious about the difference that jumps out.

How are you running the Terminal as admin? Via some mechanism in the OS (like right-clicking on the taskbar, or via the Start Menu), or are you using the Terminal's built-in "run this profile elevated" functionality/?

(note to self: this isn't going to be a defterm thing, cause obviously, defterm doesn't work for an elevated powershell.exe)

@zadjii-msft commented on GitHub (Jan 16, 2023): What's the environment in each type of session (elevated vs unelevated)? I just wanna see if there's anything immediately obvious about the difference that jumps out. How are you running the Terminal as admin? Via some mechanism in the OS (like right-clicking on the taskbar, or via the Start Menu), or are you using the Terminal's built-in "run this profile elevated" functionality/? (note to self: this isn't going to be a defterm thing, cause obviously, defterm doesn't work for an elevated powershell.exe)
Author
Owner

@SteseDav commented on GitHub (Jan 16, 2023):

HI,

Sorry, i'm not following specifically what you mean by environment here. I'm on a Windows 11 machine, with local admin rights to the machine. (sorry if I'm being dense).

I'm using Terminals inbuilt 'Run this profile as Administrator' option.

Regards,

Steve D.

@SteseDav commented on GitHub (Jan 16, 2023): HI, Sorry, i'm not following specifically what you mean by environment here. I'm on a Windows 11 machine, with local admin rights to the machine. (sorry if I'm being dense). I'm using Terminals inbuilt 'Run this profile as Administrator' option. Regards, Steve D.
Author
Owner

@zadjii-msft commented on GitHub (Jan 16, 2023):

Oh sorry, I meant PATH when I said "environment". Whoops, that's on me 🤦

@zadjii-msft commented on GitHub (Jan 16, 2023): Oh sorry, I meant `PATH` when I said "environment". Whoops, that's on me :facepalm:
Author
Owner

@SteseDav commented on GitHub (Jan 16, 2023):

Ahh! I see... I have simply added a folder to the path variable. In the path below, it's highlighted in bold text.

PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;%ONEDRIVE%\Documents\Code_Script;C:\Users\SDavison\AppData\Local\Microsoft\WindowsApps;;C:\Users\SDavison\AppData\Local\Programs\Microsoft VS Code\bin

@SteseDav commented on GitHub (Jan 16, 2023): Ahh! I see... I have simply added a folder to the path variable. In the path below, it's highlighted in **bold text**. PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;**%ONEDRIVE%\Documents\Code_Script**;C:\Users\SDavison\AppData\Local\Microsoft\WindowsApps;;C:\Users\SDavison\AppData\Local\Programs\Microsoft VS Code\bin
Author
Owner

@zadjii-msft commented on GitHub (Jan 19, 2023):

Sorry, to extra clarify - is that the PATH in an unelevated window, or the PATH in an elevated (admin) window?

What's the PATH look like for the other type of window?

@zadjii-msft commented on GitHub (Jan 19, 2023): Sorry, to extra clarify - is that the `PATH` in an unelevated window, or the `PATH` in an elevated (admin) window? What's the `PATH` look like for the other type of window?
Author
Owner

@ghost commented on GitHub (Jan 23, 2023):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jan 23, 2023): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@SteseDav commented on GitHub (Jan 24, 2023):

That's the system environment PATH, its from neither window.

@SteseDav commented on GitHub (Jan 24, 2023): That's the system environment PATH, its from neither window.
Author
Owner

@zadjii-msft commented on GitHub (Jan 24, 2023):

Gotcha - so, what does PATH look like in each of an elevated/unelevated window/? Maybe there's some diff in one of those PATHs (when compared to what it should be) that might give us a clue as to where the issue is originating.

This might get better in 1.17 after #14637, so I might also have you try out that build (when we release it later today)

@zadjii-msft commented on GitHub (Jan 24, 2023): Gotcha - so, what does PATH look like in each of an elevated/unelevated window/? Maybe there's some diff in one of those PATHs (when compared to what it _should_ be) that might give us a clue as to where the issue is originating. This might get better in 1.17 after #14637, so I might also have you try out that build (when we release it later today)
Author
Owner

@ghost commented on GitHub (Jan 28, 2023):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jan 28, 2023): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19217