Raspbian shutdown from Windows IoT Core












1















I am building a Windows UWP app in Visual Studio which is running on a Raspberry Pi 3B. From this I would like to shutdown / reboot another Raspberry Pi running Raspbian.
Is that possible and how?
Thank you in advance










share|improve this question





























    1















    I am building a Windows UWP app in Visual Studio which is running on a Raspberry Pi 3B. From this I would like to shutdown / reboot another Raspberry Pi running Raspbian.
    Is that possible and how?
    Thank you in advance










    share|improve this question



























      1












      1








      1








      I am building a Windows UWP app in Visual Studio which is running on a Raspberry Pi 3B. From this I would like to shutdown / reboot another Raspberry Pi running Raspbian.
      Is that possible and how?
      Thank you in advance










      share|improve this question
















      I am building a Windows UWP app in Visual Studio which is running on a Raspberry Pi 3B. From this I would like to shutdown / reboot another Raspberry Pi running Raspbian.
      Is that possible and how?
      Thank you in advance







      uwp raspbian windows-10-iot-core






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 5:48









      Xavier Xie - MSFT

      5,0711315




      5,0711315










      asked Dec 29 '18 at 15:59









      henrikl2000henrikl2000

      2214




      2214
























          1 Answer
          1






          active

          oldest

          votes


















          3














          Yes, it is possible. You can use a SSH client such as Chilkat.Ssh or Asmodat.Standard.SSH.NET in UWP app to connect to the Raspbian, and then send the shutdown/reboot command( e.g.sudo shutdown –h now) to it. Asmodat.Standard.SSH.NET if a free library, but Chilkat.Ssh is not. You can find some other SSH libraries which could support .Net Standard 2.0/UAP 10.



          Update:



          The following code snippet is with using Asmodat.Standard.SSH.NET library. It works in my UWP app run on Windows IoT Core.



          C#:



              private async void ButtonReboot_Click(object sender, RoutedEventArgs e)
          {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
          {
          using (var client = new SshClient("xxx.xxx.xxx.xxx", "xx", "xxxxxxx"))
          {
          client.Connect();
          var command = client.CreateCommand("sudo reboot -f");
          var asyncResult = command.BeginExecute();
          var reader = new StreamReader(command.OutputStream);

          while (!asyncResult.IsCompleted)
          {
          await reader.ReadToEndAsync();
          }

          command.EndExecute(asyncResult);

          client.Disconnect();
          }
          });
          }


          VB.NET



          Private Async Sub ButtonReboot_Click(sender As Object, e As RoutedEventArgs)

          Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          Async Sub()
          Using sClient = New SshClient("XXX.XXX.XXX", "XX", "XXXX")
          sClient.Connect()
          If sClient.IsConnected Then
          Dim sCommand = sClient.CreateCommand("sudo reboot -f rn")
          Dim asyncResult = sCommand.BeginExecute()
          Dim reader = New StreamReader(sCommand.OutputStream)

          While Not asyncResult.IsCompleted
          Await reader.ReadToEndAsync()
          End While

          sCommand.EndExecute(asyncResult)

          Debug.WriteLine("Reboot")
          sClient.Disconnect()
          End If
          End Using
          End Sub)

          End Sub





          share|improve this answer


























          • Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

            – henrikl2000
            Jan 1 at 14:20











          • @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

            – Michael Xu - MSFT
            Jan 2 at 1:43











          • @henrikl2000, i have updated my response, hope that can help you.

            – Michael Xu - MSFT
            Jan 2 at 2:02











          • Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

            – henrikl2000
            Jan 2 at 10:06











          • @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

            – Michael Xu - MSFT
            Jan 3 at 2:00











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53971079%2fraspbian-shutdown-from-windows-iot-core%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Yes, it is possible. You can use a SSH client such as Chilkat.Ssh or Asmodat.Standard.SSH.NET in UWP app to connect to the Raspbian, and then send the shutdown/reboot command( e.g.sudo shutdown –h now) to it. Asmodat.Standard.SSH.NET if a free library, but Chilkat.Ssh is not. You can find some other SSH libraries which could support .Net Standard 2.0/UAP 10.



          Update:



          The following code snippet is with using Asmodat.Standard.SSH.NET library. It works in my UWP app run on Windows IoT Core.



          C#:



              private async void ButtonReboot_Click(object sender, RoutedEventArgs e)
          {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
          {
          using (var client = new SshClient("xxx.xxx.xxx.xxx", "xx", "xxxxxxx"))
          {
          client.Connect();
          var command = client.CreateCommand("sudo reboot -f");
          var asyncResult = command.BeginExecute();
          var reader = new StreamReader(command.OutputStream);

          while (!asyncResult.IsCompleted)
          {
          await reader.ReadToEndAsync();
          }

          command.EndExecute(asyncResult);

          client.Disconnect();
          }
          });
          }


          VB.NET



          Private Async Sub ButtonReboot_Click(sender As Object, e As RoutedEventArgs)

          Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          Async Sub()
          Using sClient = New SshClient("XXX.XXX.XXX", "XX", "XXXX")
          sClient.Connect()
          If sClient.IsConnected Then
          Dim sCommand = sClient.CreateCommand("sudo reboot -f rn")
          Dim asyncResult = sCommand.BeginExecute()
          Dim reader = New StreamReader(sCommand.OutputStream)

          While Not asyncResult.IsCompleted
          Await reader.ReadToEndAsync()
          End While

          sCommand.EndExecute(asyncResult)

          Debug.WriteLine("Reboot")
          sClient.Disconnect()
          End If
          End Using
          End Sub)

          End Sub





          share|improve this answer


























          • Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

            – henrikl2000
            Jan 1 at 14:20











          • @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

            – Michael Xu - MSFT
            Jan 2 at 1:43











          • @henrikl2000, i have updated my response, hope that can help you.

            – Michael Xu - MSFT
            Jan 2 at 2:02











          • Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

            – henrikl2000
            Jan 2 at 10:06











          • @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

            – Michael Xu - MSFT
            Jan 3 at 2:00
















          3














          Yes, it is possible. You can use a SSH client such as Chilkat.Ssh or Asmodat.Standard.SSH.NET in UWP app to connect to the Raspbian, and then send the shutdown/reboot command( e.g.sudo shutdown –h now) to it. Asmodat.Standard.SSH.NET if a free library, but Chilkat.Ssh is not. You can find some other SSH libraries which could support .Net Standard 2.0/UAP 10.



          Update:



          The following code snippet is with using Asmodat.Standard.SSH.NET library. It works in my UWP app run on Windows IoT Core.



          C#:



              private async void ButtonReboot_Click(object sender, RoutedEventArgs e)
          {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
          {
          using (var client = new SshClient("xxx.xxx.xxx.xxx", "xx", "xxxxxxx"))
          {
          client.Connect();
          var command = client.CreateCommand("sudo reboot -f");
          var asyncResult = command.BeginExecute();
          var reader = new StreamReader(command.OutputStream);

          while (!asyncResult.IsCompleted)
          {
          await reader.ReadToEndAsync();
          }

          command.EndExecute(asyncResult);

          client.Disconnect();
          }
          });
          }


          VB.NET



          Private Async Sub ButtonReboot_Click(sender As Object, e As RoutedEventArgs)

          Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          Async Sub()
          Using sClient = New SshClient("XXX.XXX.XXX", "XX", "XXXX")
          sClient.Connect()
          If sClient.IsConnected Then
          Dim sCommand = sClient.CreateCommand("sudo reboot -f rn")
          Dim asyncResult = sCommand.BeginExecute()
          Dim reader = New StreamReader(sCommand.OutputStream)

          While Not asyncResult.IsCompleted
          Await reader.ReadToEndAsync()
          End While

          sCommand.EndExecute(asyncResult)

          Debug.WriteLine("Reboot")
          sClient.Disconnect()
          End If
          End Using
          End Sub)

          End Sub





          share|improve this answer


























          • Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

            – henrikl2000
            Jan 1 at 14:20











          • @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

            – Michael Xu - MSFT
            Jan 2 at 1:43











          • @henrikl2000, i have updated my response, hope that can help you.

            – Michael Xu - MSFT
            Jan 2 at 2:02











          • Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

            – henrikl2000
            Jan 2 at 10:06











          • @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

            – Michael Xu - MSFT
            Jan 3 at 2:00














          3












          3








          3







          Yes, it is possible. You can use a SSH client such as Chilkat.Ssh or Asmodat.Standard.SSH.NET in UWP app to connect to the Raspbian, and then send the shutdown/reboot command( e.g.sudo shutdown –h now) to it. Asmodat.Standard.SSH.NET if a free library, but Chilkat.Ssh is not. You can find some other SSH libraries which could support .Net Standard 2.0/UAP 10.



          Update:



          The following code snippet is with using Asmodat.Standard.SSH.NET library. It works in my UWP app run on Windows IoT Core.



          C#:



              private async void ButtonReboot_Click(object sender, RoutedEventArgs e)
          {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
          {
          using (var client = new SshClient("xxx.xxx.xxx.xxx", "xx", "xxxxxxx"))
          {
          client.Connect();
          var command = client.CreateCommand("sudo reboot -f");
          var asyncResult = command.BeginExecute();
          var reader = new StreamReader(command.OutputStream);

          while (!asyncResult.IsCompleted)
          {
          await reader.ReadToEndAsync();
          }

          command.EndExecute(asyncResult);

          client.Disconnect();
          }
          });
          }


          VB.NET



          Private Async Sub ButtonReboot_Click(sender As Object, e As RoutedEventArgs)

          Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          Async Sub()
          Using sClient = New SshClient("XXX.XXX.XXX", "XX", "XXXX")
          sClient.Connect()
          If sClient.IsConnected Then
          Dim sCommand = sClient.CreateCommand("sudo reboot -f rn")
          Dim asyncResult = sCommand.BeginExecute()
          Dim reader = New StreamReader(sCommand.OutputStream)

          While Not asyncResult.IsCompleted
          Await reader.ReadToEndAsync()
          End While

          sCommand.EndExecute(asyncResult)

          Debug.WriteLine("Reboot")
          sClient.Disconnect()
          End If
          End Using
          End Sub)

          End Sub





          share|improve this answer















          Yes, it is possible. You can use a SSH client such as Chilkat.Ssh or Asmodat.Standard.SSH.NET in UWP app to connect to the Raspbian, and then send the shutdown/reboot command( e.g.sudo shutdown –h now) to it. Asmodat.Standard.SSH.NET if a free library, but Chilkat.Ssh is not. You can find some other SSH libraries which could support .Net Standard 2.0/UAP 10.



          Update:



          The following code snippet is with using Asmodat.Standard.SSH.NET library. It works in my UWP app run on Windows IoT Core.



          C#:



              private async void ButtonReboot_Click(object sender, RoutedEventArgs e)
          {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
          {
          using (var client = new SshClient("xxx.xxx.xxx.xxx", "xx", "xxxxxxx"))
          {
          client.Connect();
          var command = client.CreateCommand("sudo reboot -f");
          var asyncResult = command.BeginExecute();
          var reader = new StreamReader(command.OutputStream);

          while (!asyncResult.IsCompleted)
          {
          await reader.ReadToEndAsync();
          }

          command.EndExecute(asyncResult);

          client.Disconnect();
          }
          });
          }


          VB.NET



          Private Async Sub ButtonReboot_Click(sender As Object, e As RoutedEventArgs)

          Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
          Async Sub()
          Using sClient = New SshClient("XXX.XXX.XXX", "XX", "XXXX")
          sClient.Connect()
          If sClient.IsConnected Then
          Dim sCommand = sClient.CreateCommand("sudo reboot -f rn")
          Dim asyncResult = sCommand.BeginExecute()
          Dim reader = New StreamReader(sCommand.OutputStream)

          While Not asyncResult.IsCompleted
          Await reader.ReadToEndAsync()
          End While

          sCommand.EndExecute(asyncResult)

          Debug.WriteLine("Reboot")
          sClient.Disconnect()
          End If
          End Using
          End Sub)

          End Sub






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 9:47

























          answered Dec 31 '18 at 7:30









          Michael Xu - MSFTMichael Xu - MSFT

          2,276128




          2,276128













          • Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

            – henrikl2000
            Jan 1 at 14:20











          • @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

            – Michael Xu - MSFT
            Jan 2 at 1:43











          • @henrikl2000, i have updated my response, hope that can help you.

            – Michael Xu - MSFT
            Jan 2 at 2:02











          • Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

            – henrikl2000
            Jan 2 at 10:06











          • @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

            – Michael Xu - MSFT
            Jan 3 at 2:00



















          • Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

            – henrikl2000
            Jan 1 at 14:20











          • @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

            – Michael Xu - MSFT
            Jan 2 at 1:43











          • @henrikl2000, i have updated my response, hope that can help you.

            – Michael Xu - MSFT
            Jan 2 at 2:02











          • Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

            – henrikl2000
            Jan 2 at 10:06











          • @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

            – Michael Xu - MSFT
            Jan 3 at 2:00

















          Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

          – henrikl2000
          Jan 1 at 14:20





          Happy New Year. Thank you very much for your reply. Unfortunately, Chilkat is not free. Is there a different solution?

          – henrikl2000
          Jan 1 at 14:20













          @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

          – Michael Xu - MSFT
          Jan 2 at 1:43





          @henrikl2000, you can use Asmodat.Standard.SSH.NET. This is .NET Core / Net Standard 2.0 release of Renci SSH.NET library. I have tested with this library, it works. At first i tried to use SSH.NET, i thought it would support UAP 10.0, but i got the error 'Server response does not contain SSH protocol identification'.

          – Michael Xu - MSFT
          Jan 2 at 1:43













          @henrikl2000, i have updated my response, hope that can help you.

          – Michael Xu - MSFT
          Jan 2 at 2:02





          @henrikl2000, i have updated my response, hope that can help you.

          – Michael Xu - MSFT
          Jan 2 at 2:02













          Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

          – henrikl2000
          Jan 2 at 10:06





          Hi Michael, I have tested Asmodat.Standard.SSH.NET in my UWP code and it works using the IP address or name of the Raspberry Pi. The Raspberry Pi reboots using your example, but my program hangs after sending the ssh command. Do you know a solution to that?

          – henrikl2000
          Jan 2 at 10:06













          @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

          – Michael Xu - MSFT
          Jan 3 at 2:00





          @henrikl2000, you can use BeginExecute method which is asynchronous instead of RunCommand method,

          – Michael Xu - MSFT
          Jan 3 at 2:00


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53971079%2fraspbian-shutdown-from-windows-iot-core%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas