on click my windows will shutdown i'm developing an metro app for windows 8.1 using c# language
using libraries
using System.Diagnostics; using System.Runtime.InteropServices;
the action is
private void Button_Click(object sender, RoutedEventArgs e) { Process.Start("shutdown", "/s /t 0"); }
red bar in "Process"
so why it couldn't read Progress and is there any other method , Thanks
Metro apps only have a limited subset of classes that are useable, the Process class is one of the removed classes. If a class does not have the windows store icon (
) on the MSDN when you are looking in the namespace view then the class is not available for use in metro apps.
Metro apps are sandboxed and can not interact with other processes nor spawn new processes themselves so there are no alternatives for running shutdown.exe unless you are willing to make your app a desktop app instead of a metro app.
Taking a look at "Alternatives to Windows APIs in Windows Store apps" you can see that there is no metro equivalent to the User: shutdown API either.
If you absolutely don't want to create a desktop app but still want to be able to shut down the only other work around I can think of is to have a second program that runs as a system service that your metro app can talk to via some form of IPC. That way you can have your metro app send a request to the service then the service is what will actually initiate the shutdown command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With