Skip to content
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

"Open as administrator" launches UWP apps without elevated permissions #605

Closed
monster1612 opened this issue Jul 4, 2021 · 4 comments · Fixed by #641
Closed

"Open as administrator" launches UWP apps without elevated permissions #605

monster1612 opened this issue Jul 4, 2021 · 4 comments · Fixed by #641
Assignees

Comments

@monster1612
Copy link

Describe the bug
when using Cairo to launch a UWP app (such as Windows Terminal or PowerShell Preview) via right-click -> "Open as administrator", no UAC prompt appears and the app is launched without elevated permissions.

Steps to reproduce

  1. install a UWP app (for example, Windows Terminal).
  2. add a shortcut for the app to Cairo via App Grabber or Quick Launch.
  3. right-click on the app shortcut, and then click "Open as administrator".
  4. no UAC prompt appears, and the program does not indicate it is running as administrator.

Expected behavior
a UAC prompt should appear for the app.

System information:

  • Windows version: Windows 11, Insider build 22000.51
  • Cairo version: 0.4.133.47321
  • 32-bit or 64-bit: 64-bit
  • In Cairo Settings > Advanced, is Cairo set as shell?: no.

Additional context
if launched via the dynamic desktop (or when the desktop is enabled in Cairo), the UAC prompt appears correctly when using right-click -> Run as administrator.

non-UWP apps, like DIscord, correctly trigger UAC prompts if launched via "Open as adminstrator".

Screenshots
N/A.

@dremin
Copy link
Collaborator

dremin commented Oct 6, 2021

Hm, I don't think UWP apps can run elevated in any scenario. It probably makes sense to hide this option for UWP apps.

@dremin dremin self-assigned this Oct 6, 2021
@monster1612
Copy link
Author

monster1612 commented Nov 3, 2021

(apologies for bumping this dormant issue thread; I've been pretty busy with school.)

I've been noticing that Windows Terminal can in fact be run as administrator when launched via the Start Menu, and it behaves pretty much like Command Prompt or PowerShell do when launched in an elevated fashion. (WT is basically just PowerShell with tabs.)

the curious thing here is that when using PowerToys Run (acts similar to Spotlight on a Mac), Windows Terminal can be directly executed as an administrator like it can in the Start Menu. the underlying file launched here is the WindowsTerminal.exe binary (see below screenshot), which I can't manually invoke with administrator permissions if I right-click on the file in File Explorer and then just choose "Run as administrator". (that throws an error, and I'm guessing Cairo programmatically is trying and failing to elevate it with that same approach.)

I did some digging around in the PowerToys repo to see if I could try to pick apart specific functions that handle the actual elevation request, and all I've found so far are files that check whether programs can be elevated (via CanFileBeRunAsAdmin) and attempt elevation (via RunAsAdmin?).

I know this likely would involve some amount of work on your end, so no worries if you can't/aren't willing to look into it; I thought I should at least try to point in the right direction for a working example.

WindowsTerminal - elevated through PowerToys Run

@dremin
Copy link
Collaborator

dremin commented Nov 3, 2021

Hm, this is intriguing. The above links show that PowerToys is running the app as admin in the exact same way we run win32 apps as admin. However, we launch UWP apps differently than win32 apps. I've had issues running UWP exe files directly in the past, but this shows it can work, so I'll need to do some testing to see what we can do in this scenario.

@dremin
Copy link
Collaborator

dremin commented Nov 28, 2021

Ah, I've figured it out. Launching directly from shell:appsfolder seems to run as admin for apps that allow it. I'll need to check the app manifest for if the app allows running as admin.

dremin added a commit that referenced this issue Nov 28, 2021
Refactored AppGrabberService to reduce nesting
Saves if app allows run as admin to config file with migration process
Fixed admin dialog not saving
Fixed quick launch context menu not hiding admin option
Fixed quick launch context menu not having run as user option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants