# Net rpc shutdown

**URL:** https://community.homey.app/t/net-rpc-shutdown/2633
**Category:** Questions & Help
**Created:** [October 9, 2018, 2:09pm UTC](https://community.homey.app/t/net-rpc-shutdown/2633 "2018-10-09T14:09:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Some1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/some1/32/8283_2.png) [@Some1](https://community.homey.app/u/Some1)
#### Post date: [October 9, 2018, 2:09pm UTC](https://community.homey.app/t/net-rpc-shutdown/2633/1 "2018-10-09T14:09:05Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![johan\_bendz](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johan_bendz/32/10344_2.png) [@johan\_bendz](https://community.homey.app/u/johan_bendz)
#### Post date: [October 9, 2018, 10:29pm UTC](https://community.homey.app/t/net-rpc-shutdown/2633/2 "2018-10-09T22:29:26Z")

</div>

Did you look into using the SSH client? [https://apps.athom.com/app/nl.marcovantklooster.sshclient](https://apps.athom.com/app/nl.marcovantklooster.sshclient)

---

<div class="post-metadata">

### Author: ![Some1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/some1/32/8283_2.png) [@Some1](https://community.homey.app/u/Some1)
#### Post date: [October 10, 2018, 7:09am UTC](https://community.homey.app/t/net-rpc-shutdown/2633/3 "2018-10-10T07:09:24Z")

</div>

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](https://www.npmjs.com/package/node-powershell), just not sure if I can automate that. As [here](https://blogs.technet.microsoft.com/heyscriptingguy/2012/12/24/powertip-use-powershell-to-shut-down-a-remote-computer/) 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](https://social.technet.microsoft.com/Forums/en-US/b821b53f-2531-42c7-ae09-6caeef4a89c8/remote-pc-shutdown-script?forum=winserverpowershell) 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.

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [October 10, 2018, 10:38am UTC](https://community.homey.app/t/net-rpc-shutdown/2633/4 "2018-10-10T10:38:00Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![Some1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/some1/32/8283_2.png) [@Some1](https://community.homey.app/u/Some1)
#### Post date: [October 10, 2018, 11:26am UTC](https://community.homey.app/t/net-rpc-shutdown/2633/5 "2018-10-10T11:26:28Z")

</div>

> [@robertklep](#):
>
> Just remember: Homey doesn’t run Windows, so any Windows commands that you are trying to run on Homey (using `child_process` ) will fail.

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.

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [October 10, 2018, 11:51am UTC](https://community.homey.app/t/net-rpc-shutdown/2633/6 "2018-10-10T11:51:45Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Vleege](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vleege/32/10940_2.png) [@Vleege](https://community.homey.app/u/Vleege)
#### Post date: [October 10, 2018, 2:10pm UTC](https://community.homey.app/t/net-rpc-shutdown/2633/7 "2018-10-10T14:10:50Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![Some1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/some1/32/8283_2.png) [@Some1](https://community.homey.app/u/Some1)
#### Post date: [October 10, 2018, 7:14pm UTC](https://community.homey.app/t/net-rpc-shutdown/2633/8 "2018-10-10T19:14:39Z")

</div>

> [@robertklep](#):
>
> 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

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.
