Raspbian shutdown from Windows IoT Core
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
add a comment |
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
add a comment |
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
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
uwp raspbian windows-10-iot-core
edited Dec 31 '18 at 5:48
Xavier Xie - MSFT
5,0711315
5,0711315
asked Dec 29 '18 at 15:59
henrikl2000henrikl2000
2214
2214
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
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 useBeginExecute
method which is asynchronous instead ofRunCommand
method,
– Michael Xu - MSFT
Jan 3 at 2:00
|
show 7 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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 useBeginExecute
method which is asynchronous instead ofRunCommand
method,
– Michael Xu - MSFT
Jan 3 at 2:00
|
show 7 more comments
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
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 useBeginExecute
method which is asynchronous instead ofRunCommand
method,
– Michael Xu - MSFT
Jan 3 at 2:00
|
show 7 more comments
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
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
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 useBeginExecute
method which is asynchronous instead ofRunCommand
method,
– Michael Xu - MSFT
Jan 3 at 2:00
|
show 7 more comments
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 useBeginExecute
method which is asynchronous instead ofRunCommand
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
|
show 7 more comments
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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