0

Which API can I use about shutdown or restart in UWP Code?

And how can I turn off IoT Core automatic update?

In addition, after resetting advfirewall rules, all remote tools (Device Portal or Windows file sharing) can't be used to manage my device. How can I get them working again?

1
  • Which IoT version did you use?After resetting advfirewall, did you reboot your device?I have tested in 15063, after resetting advfirewall, device portal can connect to the device,but powershell can not. When i set allprofiles state on(load device portal and run command "netsh advfirewall set allprofiles state on" without checked 'Run as DefaultAccount'), can use powershell to connect.
    – Michael Xu
    Nov 2, 2017 at 2:09

1 Answer 1

2

Reset / Shutdown

The Windows IoT Extensions for the UWP offer the ability to restart and shutdown the device.

First you have to add the extensions to your app. You can do this by right-clicking the UWP project in the solution explorer and choosing Add -> Reference. Now in the left-hand panel choose the Universal Windows -> Extensions section and then check the checkbox by the Windows IoT Extensions for the UWP extension.

Then you also need to add a special capability to your Package.appxmanifest. Open it as XML text file and in the <Capabilities> node add the following:

<iot:Capability Name="systemManagement" />

You can then use the ShutdownManager class to perform shutdown / restart.

// Shutdown
ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));

// Restart after 3 seconds:
ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(3));

The second parameter allows you to specify when the operation should take place.

Preventing update

A way to prevent automatic update is described here in a blog post.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.