Chris Spittles
Chris Spittles

Reputation: 15359

Best way to trigger shutdown/restart from metro app in Windows 8

I'm just getting started with Windows 8 app development. As a first project I've created a metro app that should be able to shutdown, restart logoff a user from the computer. The interface is all done, but I'm not sure how to go about shutting it down. Is it possible to use the following and if so do you have an example?

%windir%\System32\shutdown.exe /s /t 0

Or is there something in the APi I could call? If not could I perhaps include a .bat file in the project and call that to initiate shutdown?

Many thanks

Chris

Upvotes: 1

Views: 528

Answers (1)

ZombieSheep
ZombieSheep

Reputation: 29953

To the best of my knowledge this is not possible, and it is certainly not possible using the method you outlined above. Windows Store apps (the apps formerly known as "Metro") run in a heavily sandboxed enviropnment, and as such you don't get any access to the Windows directory in order to call shutdown.exe. The security model in place (should) make(s) it virtually impossible to complete tasks like a reboot or shutdown operation - that is (and should be) firmly in the domain of the user to decide rather than an app.

Upvotes: 2

Related Questions