1

I have a UWP app running in assigned access mode on a windows tablet without a physical keyboard. Once the user finishes the operation I want to let the user shutdown the tablet ( Can't Alt+CTRL+DEL and shutdown as there is no physical keyboard). I know there are no API from UWP to shutdown the tablet. but is there any workarounds? How is Microsoft handling this scenario?

1 Answer 1

3

This is not achievable within UWP application, which runs inside an App Container, and don't have such privilege.

However, you can try out the Brokered Windows Runtime Components for side-loaded Windows Store apps. Essentially, it allows you UWP app to call Win32 API hosted in a different process, which runs outside of the App container.

Inside your brokered component, you can use below code to shut down your PC.

var psi = new ProcessStartInfo("shutdown", "/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);

Below is the brokered WinRT component template for VS2015 https://visualstudiogallery.msdn.microsoft.com/d2e9cac0-66a8-464a-a902-55ae765c8e6e?tduid=(c5f2776eb12ea55b8926d0c075062c9d)(256380)(2459594)(TnL5HPStwNw-gN1OuW5VyKxMyOTAH.bK0w)()

Below is a very good example for creating brokered components for UWP, https://xamltips.wordpress.com/2015/11/13/brokered-component-for-uwp-on-windows-10/

For more information, see to https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx

Sign up to request clarification or add additional context in comments.

5 Comments

I used a windows service interacting with App using TCP. and it worked!
Ha, that's also a hack.
@Suneesh I tried the same thing, but UWP doesn't allow loop back. did you use "checknetisolation loopbackexempt" to exempt the application?
@Sam I ran a windows service with TCP server which ran on elevated privilege. I can't tell you for sure, but I think I have added code in the service installer to add "checknetisolation loopbackexempt" for the app. I don't have the source code of the app now.
@Jackie, using shutdown.exe shows me a login screen briefly. Could it be avoided? I tested that login screen does not come when not in assigned access mode (i.e. running an app from the desktop).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.