-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run As Administrator #1872
Comments
@DHowett-MSFT I could've swore we had a duplicate issue sitting around somewhere for this, but I can't find it now. Do you remember what causes this? |
Ahh man, sorry if it is a duplicate. there is no reason, start the app fine but r-click and start as admin fails, windows UAC prompt for admin password twice then you get the error. |
Windows Terminal support running in admin mode may not be a good behavior, which means that all shells in other tabs opened from Ctrl+T may be administrator privilege. As far as I know, Windows Terminal does not implement any code from the Administrator to the restricted user. In fact, what Windows lacks is the kind of privilege implementation that does not require UI interaction, like sudo. But implementing sudo can also be cumbersome. The flow of runas verb is roughly as follows (if anything is wrong, please remind me):
We can draw a simple conclusion. In fact, AppInfo does not currently support setting up a working directory, input and output (although calling CreateProcessAsUser) when launching the administrator process. This is a problem that needs to be solved to enable sudo support to run in Windows Terminal. (ShellExecuteEx SEE_MASK_NO_CONSOLE not work) typedef struct _SHELLEXECUTEINFOW {
DWORD cbSize;
ULONG fMask;
HWND hwnd;
LPCWSTR lpVerb;
LPCWSTR lpFile;
LPCWSTR lpParameters;
LPCWSTR lpDirectory;
int nShow;
HINSTANCE hInstApp;
void *lpIDList;
LPCWSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
union {
HANDLE hIcon;
HANDLE hMonitor;
} DUMMYUNIONNAME;
HANDLE hProcess;
} SHELLEXECUTEINFOW, *LPSHELLEXECUTEINFOW;
|
This is definitely a windows platform issue. I'm assigning it to myself to follow up with the team that owns it and close this out. Thanks. |
I like @YMba9g8j9CJp0wLoQf5y’s proposal of authorizing a tab with escalated privilege. I’m from ConEmu where we can create a tab with or without admin privilege. When creating an admin tab I will be prompted with UAC (for good). |
Is this not just normal behavior of Windows store applications? This looks like the Preview app recently released. |
Hey, we're not sure there's anything we can do about this. Would you mind filing feedback in the "Developer Platform > App Deployment" category? That'll help get it routed to the right team, and collects some very useful diagnostic information. |
Linking: this is also #1538 |
Even though I agree with the decision. It does make it quite painful to use |
@musm I just have this in my PowerShell 6 config:
(replace So whenever I need to install/update packages via chocolatey I type I would definitely like a way to launch |
Actually it never worked, the last comment I got was, it is a Windows issue and they will raise it with the team. |
I don’t think so. It’s more like “you should raise it with the team”. |
Im sure they're not thinking of releasing Win Terminal v1 with one of the most important functionality broken. |
@DHowett-MSFT Which issue should we follow and star to get this resolved? The only other referenced issue I can see is #1538 which is also closed. I'm sure Microsoft's stance can't be that everybody should have administrative rights on their standard user instead of using a separate admin account if they want to use modern Windows apps. This is after all contrary to standard security practices. |
@danstur Best I can offer for that concern is #4217. We're pursuing a fix with the team who owns app deployment. The issue is that apps are installed globally, but only registered per-user. This was some infrastructure that was built for Windows 8 that has only very slowly evolved to support even running standard win32 applications like Terminal. #1386 tracks us getting out of the package and distributing as something more traditional for enterprise customers and folks who are having trouble with the package deployment engine. |
@DHowett-MSFT Thanks for the issues, glad to hear that it's being tracked. To clarify: If I install the application via the options mentioned in #1386 will I then be able to run it as a different user or would that still not work? I wouldn't mind having to register the app (does that mean running |
That should work fine. You'll need to Add-AppxPackage as those users, yes. 😄 |
Glad to see its being tacked. This need to be resolved, as now in any Windows environment set up with separate admin and user accounts (as it should be) the terminal is not usable for admins if installed from the (recommended) MS Store |
A workaround that worked for me was logging in as the admin user in the local machine and "install" again the terminal from the Store. Then, when logged as a standard user, I could run the terminal as an administrator |
Yes the problem seems to be Store registers the app for current user only. That is fine for most apps (actually thats how most apps should be installed anyway) but is not good for administrative apps like terminals. |
Hey future me: the store registration issue is being tracked internally with MSFT:20356613 and discussed at length in #4217 |
Hello, |
Same here. problem seems not to be solved |
I have yet another less-than-perfect workaround which doesn't allow opening a tab running as administrator, but it does allow opening a PowerShell window as Administrator from an existing (non-admin) tab: https://github.com/jt-github/elevate This works the same way as adding the profile as suggested by @CraigHead above: Except that my my version is executed by running the |
@jt-github That's like sudo. See here: https://github.com/pldmgg/Sudo |
Exactly, only |
Like many of you, I have also run into this issue, so I created the following functions in order to open an Admin shell from either powershell.exe, pwsh.exe or Microsoft terminal # Function Test-IsAdmin
function Test-IsAdmin {
<#
.Synopsis
Tests if the user is an administrator
.Description
Returns true if a user is an administrator, false if the user is not an administrator
.Example
Test-IsAdmin
#>
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal $identity
$principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
# Function New-AdminShell
function New-AdminShell {
<#
.Synopsis
Starts an Elevated PowerShell Console.
.Description
Opens a new PowerShell Console Elevated as Administrator. If the user is already running an elevated
administrator shell, a message is displayed in the console session.
.Example
New-AdminShell
#>
$Process = Get-Process | Where-Object { $_.Id -eq "$($PID)" }
if (Test-IsAdmin = $True) {
Write-Warning -Message "Admin Shell already running!"
}
else {
if ($Process.Name -eq "powershell") {
Start-Process -FilePath "powershell.exe" -Verb runas -PassThru
}
if ($Process.Name -eq "pwsh") {
Start-Process -FilePath "pwsh.exe" -Verb runas -PassThru
}
}
}
# Function New-AdminTerminal
function New-AdminTerminal {
<#
.Synopsis
Starts an Elevated Microsoft Terminal.
.Description
Opens a new Microsoft Terminal Elevated as Administrator. If the user is already running an elevated
Microsoft Terminal, a message is displayed in the console session.
.Example
New-AdminShell
#>
if (Test-IsAdmin = $True) {
Write-Warning -Message "Admin Shell already running!"
}
else {
Start-Process "wt.exe" -ArgumentList "-p pwsh" -Verb runas -PassThru
}
} I hope someone finds them useful. I have added them to my PowerShell Profiles, so they are always available. |
This worked for me as well, its super annoying but on a corp network thats pretty much the only way that has worked for me. If you don't have local admin this app is pretty much a bust for elevated privs on a corp network. |
Nah, that didn't work for me :( |
So i figured it out. You have to have it installed in BOTH the administrator account and also in the main account, but also the administrative account must be signed in for it to work. By this, i mean that the computer has to be logged into administrator, then switch the user (not sign out) and log into the other account. This will allow the app to run in administrator mode. I'm guessing store apps installed on both accounts cannot be run as administrator unless an administrator account is logged into. |
This works for me. 👍 |
Still having the issue documented above. Tried current 1.5x and preview 1.6 as of today and either I get one UAC cred prompt and nothing happens or two cred prompts and an error like screenshot-ted above saying couldn't find file. |
I am currently not on Windows so I cannot double check this, but if I recall correctly I could run Terminal as an administrator without logging into administrative profile. Only thing I had to do once to be able to run Terminal as a privileged user was installing it in administrator account. |
This is awesome - adds registry keys to run any of the Windows Terminal shells as administrator, from the right-click context menu in Windows File Explorer |
Do not think that this issue should be considered closed. It really limits the usefulness of windows terminal in a corporate environment (where you have a user account and one administrator account). |
This actually help me!.. very nice work around |
I think everyone is missing the point. At the top someone mentioned installing with Chocolatey. I have this same problem. I believe it's because my workstation is quite long in the tooth. It's been through a few feature updates, and a while back I tried to compile a early iteration from source. Then I uninstalled it for whatever reason and tried to install it with Chocolatey. One thing let to another and probably encountered the elevation issue you all are talking about. I think there are some artifacts from previous installs causing the problem, but I don't know of a registry key, or appdata folder I can wipe out. I thought it was simply a biproduct of being a Store App (Appx), like you were all saying. Store installs in user context. After talking to people on Twitter (Jeff Hicks I think), I spun up a brand new vm and installed WT from the store. Elevation works just fine. Unless anyone here has any bright ideas, I have reserved myself to biting the bullet and rebuilding my workstation, but never a great time for that. So at the moment I cannot use the new hotness (Windows Terminal). :-( |
Did not work for me. However, I have found another work around. Run Windows built-in PowerShell as Administrator (Win+X, A) and leave it open, then run Windows Terminal as Administrator. If no need, one can exit original PowerShell session. |
@BanterBoy
had me wondering if powershell syntax had changed or maybe it was just a typo (yes, I am your 1 confused 😕). It took me a while to realise that it was neither. Though the definition of
with a clever little reminder about what type is being returned. This comment is basically an explanation for anybody else who might be wondering about it (or maybe it's just me). Though I appreciate the benefits of self-documenting code, the use of a personal mnemonic (I can't remember seeing it before) that, to a casual observer, seems like a syntax error might be better avoided on public forums, particularly where code snippets tend to be short. In this case, |
Seems there is an issue running the terminal "As Administrator"
Error: Windows cannot find "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.2.1831.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe" Make sure you've typed the name correctly, then try again
The text was updated successfully, but these errors were encountered: