Net rpc shutdown

How can I make Home send an net rpc shutdown command?

I’ve tried building my own app:
const exec = require(‘child_process’).exec;
exec("net rpc shutdown …

But then I get an error indicating that /bin/sh does not exist (Error: spawn /bin/sh ENOENT)? What is the correct way to get what I want?

Did you look into using the SSH client?


If I’m not mistaken that would require installing software on both homey and the target machines (ssh server).
If not, what would the correct command be to shut down a remote windows machine?

I could also make use of powershell, just not sure if I can automate that. As here it says it will prompt for a password. The net rpc shutdown command includes both username and password so can easily be automated.
So I figured the easiest method to remotely shut down any remote windows machine without having to install software and or change settings on the remote machine is by making use of net rpc.

On Homey I am required to install software for this cause either way, so why not build something that makes shutting down remote computers easy?

Edit: will probably go for the powershell method, as credentials can be entered from a script. And for the stop-computer command powershell remoting is not required, so no settings need to be changed and no clientside software needs to be installed.

Just remember: Homey doesn’t run Windows, so any Windows commands that you are trying to run on Homey (using child_process) will fail.

In your initial post you’re also running into another issue: the child_process functions won’t work anyway on Homey, because /bin/sh isn’t exposed (there are ways around that issue, but you’d still have the problem of having no command at your disposal that can be used to shut down a remote Windows machine)

But net rpc is part of samba_common, so what windows command would I be running? So if samba_common is present and usable that still might be the preferred method as then no external libraries would be required.

The powershell option is more secure (store the password after ConvertTo-SecureString) so in that respect the better choice. Sadly it does have a few more dependencies resulting in a far bigger claim on system resources. And my homey is already complaining that due to the number of apps the system might become slower.

You can’t run any Windows commands on Homey directly, using child_process, because those commands aren’t available.

Even if there are Linux packages that provide similar commands (I assume that’s what you mean with samba-common), you can’t a) assume that those packages are installed (Homey is a limited-resources hardware platform so any packages that are not directly required for it to run won’t be installed) and b) assume that if they are installed, they are made available inside the “sandbox” that each Homey app runs in.

I don’t see an obvious solution for what you want to do, apart from finding a pure Node.js package that implements something similar to the net command, or using the aforementioned SSH app (which would require running an SSH server on your Windows machine, as you already pointed out).

Very complicated way of asking how to shutdown a Windows client. Use Airytec Switch Off. Simple little server app on your Windows machine which can do so much more than what you are asking but can do that little trick too. It will require you to install a tiny little app…

Indeed, as node-powershell requires a sepparate installation of … powershell. There I was thinking it was a powershell client in itself, not so apparently.

nodejs does have a net module, sadly I would not know what to do with it to reproduce what net rpc does. And have yet to find documentation that explains it. As I understand RPC handles authentication, net does not.