{"id":352,"date":"2017-01-04T10:35:40","date_gmt":"2017-01-04T10:35:40","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=352"},"modified":"2017-01-04T10:35:40","modified_gmt":"2017-01-04T10:35:40","slug":"shutdown-and-reboot","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/system-control\/shutdown-and-reboot","title":{"rendered":"Shutdown and reboot"},"content":{"rendered":"<h4>\n\tRequirements To Use<br \/>\n<\/h4>\n<h5>\n\tEnable System Management capability for your app<br \/>\n<\/h5>\n<p>\n\tRight click Package.appxmanifest &gt; View Code. &nbsp;In the Capabilities sections add the following line\n<\/p>\n<pre>\n<code>\n&lt;iot:Capability Name=&quot;systemManagement&quot;\/&gt;<\/code>\n<\/pre>\n<p>\n\tIf you get a squigle red line &quot;iot not recognised type error&quot; then you need to update the start of the file xmlns as follows <em>(note the 4th xmlns entry-do you have it? &nbsp;AND&nbsp;the &quot;iot&quot; in IgnorableNamespaces-do you have it?)<\/em>:\n<\/p>\n<p style=\"margin-left: 40px\">\n\t&lt;Package<br \/>\n\txmlns=&quot;http:\/\/schemas.microsoft.com\/appx\/manifest\/foundation\/windows10&quot;<br \/>\n\txmlns:mp=&quot;http:\/\/schemas.microsoft.com\/appx\/2014\/phone\/manifest&quot;<br \/>\n\txmlns:uap=&quot;http:\/\/schemas.microsoft.com\/appx\/manifest\/uap\/windows10&quot;<br \/>\n\txmlns:iot=&quot;http:\/\/schemas.microsoft.com\/appx\/manifest\/iot\/windows10&quot;<br \/>\n\tIgnorableNamespaces=&quot;uap mp iot&quot;&gt;<br \/>\n\t.<br \/>\n\t.<br \/>\n\t.<br \/>\n\t&lt;Capabilities&gt;<br \/>\n\t&lt;iot:Capability Name=&quot;systemManagement&quot; \/&gt;<br \/>\n\t&lt;\/Capabilities&gt;\n<\/p>\n<h5>\n\tYou&nbsp;need to have &quot;Windows IoT Extension for UWP&quot; added to your project<br \/>\n<\/h5>\n<p>\n\tRight click&nbsp;on your project. Then, select Add &gt; Reference..&nbsp;\n<\/p>\n<p>\n\tSelect Universal Windows &gt; Exensions &gt; Windows IoT Extension for the UWP, select the latest version and press OK\n<\/p>\n<h5>\n\tTroubleshooting<br \/>\n<\/h5>\n<p>\n\tThe Visual Studio implementation of this is flakey, a few tips:\n<\/p>\n<p>\n\tAdd the iot:Capability just before any DeviceCapabilities if you have them, e.g. this worked for us:\n<\/p>\n<pre>\n<code>\n  &lt;Capabilities&gt;\n    &lt;Capability Name=&quot;internetClient&quot; \/&gt;\n    &lt;Capability Name=&quot;internetClientServer&quot; \/&gt;\n    &lt;uap:Capability Name=&quot;removableStorage&quot; \/&gt;\n    &lt;iot:Capability Name=&quot;systemManagement&quot; \/&gt;\n    &lt;DeviceCapability Name=&quot;serialcommunication&quot;&gt;\n      &lt;Device Id=&quot;any&quot;&gt;\n        &lt;Function Type=&quot;name:serialPort&quot; \/&gt;\n      &lt;\/Device&gt;\n    &lt;\/DeviceCapability&gt;\n  &lt;\/Capabilities&gt;\n<\/code><\/pre>\n<p>\n\tClose the Package.appcmanifest and try double clicking it to get the visual designer. &nbsp;Then re-open it in code view and check everything&nbsp;again &#8211; opening in visual mode VS does houekeeping on it and may have changed things like removed your iot from IgnorableNamespace (happened to us!)\n<\/p>\n<h4>\n\tCommands<br \/>\n<\/h4>\n<h5>\n\tShutdown<br \/>\n<\/h5>\n<pre>\n<code>\n\tWindows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Shutdown, TimeSpan.FromSeconds(1));\t\t\/\/Delay is not relevant to shutdown\n<\/code><\/pre>\n<h5>\n\tRestart<br \/>\n<\/h5>\n<pre>\n<code>\n\tWindows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Restart, TimeSpan.FromSeconds(1));\t\t\/\/Delay before restart after shutdown\n<\/code><\/pre>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirements To Use Enable System Management capability for your app Right click Package.appxmanifest &gt; View Code. &nbsp;In the Capabilities sections add the following line &lt;iot:Capability Name=&quot;systemManagement&quot;\/&gt; If you get a squigle red line &quot;iot not recognised type error&quot; then you need to update the start of the file xmlns as follows (note the 4th xmlns [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86],"tags":[],"class_list":["post-352","post","type-post","status-publish","format-standard","hentry","category-system-control"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}