question

AbhishekJakabal-9046 avatar image
0 Votes"
AbhishekJakabal-9046 asked NicoZhu-MSFT edited

How to Shutdown down PC in UWP app?

I've created a UWP app. In which, i have a button, so when the user clicks this button the system should shutdown. Please help me....

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

NicoZhu-MSFT avatar image
0 Votes"
NicoZhu-MSFT answered NicoZhu-MSFT edited

Hello, Welcome to Micorosoft Q&A,

UWP platfrom contain BeginShutdown method, but the method only applicable to IOT device, such as raspberry pie with iot specific OS. And it will not work for Windows 10 normal os, if you do want to shut down device, we suggest you use desktop bridge to make desktop extension for uwp app and shut down computer with Win32 api Process.Start("shutdown", "/s /f /t 0");.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This "Process.Start("shutdown", "/s /f /t 0");" isn't working for me. Will you please tell me a clear procedure on how to use desktop bridge to make desktop extension for uwp app and shut down computer with Win32 api???

0 Votes 0 ·

Please refer stefan's blog UWP with Desktop Extension, it contains code sample. And If the response is helpful, please click "Accept Answer" and upvote it.

0 Votes 0 ·

Ok so this thing, i've tried it. And i am already running a batch file on a button click and its running properly. But can we run another (more than one) batch file in a single application???

Like i've two buttons 1. Start 2. Shutdown. When i press 'Start' button a batch file is getting executed. Now if i press "shutdown" another batch file should get executed. Will that happen??? I hope stefans post refers to the same thing that i am talking about.

0 Votes 0 ·
Show more comments
SimpleSamples avatar image
0 Votes"
SimpleSamples answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.