X.Huang
X.Huang

Reputation: 19

Restart IoT device & Turn off automatic update

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?

Upvotes: 0

Views: 776

Answers (1)

Martin Zikmund
Martin Zikmund

Reputation: 39082

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.

Upvotes: 2

Related Questions