LOST
LOST

Reputation: 3259

How to launch a program as administrator with Desktop Bridge

I have a program, which users sometimes want to restart with administrative privileges to perform administrative tasks. Currently, it has a menu item, which does the following call:

Process.Start(new ProcessStartInfo("self.exe") { Verb = "runas" })

That works if program is installed with MSI. It displays a usual UAC prompt, which lets user to elevate the program.

However, when converted using Desktop Bridge converter, and installed the Store way, this call crashes due to insufficient privileges. Is there another way for me to (re-)start self with UAC prompt?

Alternatively, is it possible to perform elevation using COM?

I am on release branch, Creators Update btw

Upvotes: 1

Views: 1032

Answers (1)

Danilo Gasques
Danilo Gasques

Reputation: 686

Is there another way for me to (re-)start self with UAC prompt?

No. According to this page (https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-prepare, look for Your app requires UIAccess), it seems that requesting the UAC prompt from your app is not currently supported.

Remember, as a UWP app, it needs to work while running as the interactive user.

There is a one-year-old post from MSDN that answers a similar question: https://social.msdn.microsoft.com/Forums/en-US/a35b4c70-5fc6-4f1a-b80a-b11ee90105eb/uwpdesktop-bridgeproject-centennial-appconverter-convert-admin-apps?forum=wpdevelop

Alternatively, is it possible to perform elevation using COM?

Given the findings above, the answer is probably no.

If I were in your position, I would rethink these Administrative tasks. They might even be something that you would not be able to run as a UWP app anyways. For instance, any attempt to create an HKLM key will fail.

Upvotes: 1

Related Questions