Shutdown Remote Windows PC

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

raxor
Posts: 8
Joined: Friday 17 April 2015 10:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by raxor »

Shutdown Windows computer (windows 7) from domoticz: using Synology or raspberry as a Domoticz server

INSTRUCCIONS FOR RASPBERRY

you need samba-common package

Code: Select all

sudo apt-get install samba-common

Code: Select all

nano /home/pi/domoticz/scripts/shutdown_PC.sh
content of script

Code: Select all

#!/bin/sh
#Shutdown Computer
# IP of computer and admin user needed
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f
(-f parameter force shutdown)

+x script (execution permission)

Code: Select all

chmod +x /home/pi/domoticz/scripts/shutdown_PC.sh
INSTRUCCIONS FOR SYNOLOGY

synology

Code: Select all

nano /volume1/@appstore/domoticz/scripts/shutdown_PC.sh
content of script

Code: Select all

#!/bin/sh
#Shutdown Computer
# IP of computer and admin user needed
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f
(-f parameter force shutdown)

+x script (execution permission)

Code: Select all

chmod +x /volume1/@appstore/domoticz/scripts/shutdown_PC.sh
IN WINDOWS (both cases, synology or raspberry)

To no disable windows UAC you can insert reg info to accept RPC commands

In windows create reg file. enablerpcshutdown.reg

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system]
"LocalAccountTokenFilterPolicy"=dword:00000001
- Execute to add to registry (DOUBLE CLICK),

Enable remote registry service

- Execute CMD witch admin rights (search cmd in start button, right button in cmd.exe execute with admin rights)

Code: Select all

sc config RemoteRegistry start= auto
sc start RemoteRegistry
- reboot windows

In Domoticz create virtual switch
Switch type: push off button
Assign to off action:
(RASPBERRY)
"script://home/pi/domoticz/scripts/shutdown_PC.sh"
(SYNOLOGY)
"script://volume1/@appstore/domoticz/scripts/shutdown_PC.sh"
Save
Last edited by raxor on Monday 27 April 2015 9:49, edited 3 times in total.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

This script is to restart . is there might also be a shutdown and startup script ?

And may i do so without a password / login on a pc
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
raxor
Posts: 8
Joined: Friday 17 April 2015 10:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by raxor »

Nope, this script is to shutdown, and to start I use wake on lan virtual device in domoticz, is too easy, enable some values in bios menu from pc wake on events on energy management, in Windows, network controller setup, enable magic packet wake on, or wake on lan (WOL), you need mac address of your network card (pc), and IP of your network for broadcast, for example if your pc have ip 192.168.1.105 network value is 192.168.1.255.

ifconfig /all on command provide this values (cmd.exe)

If you don't like put your user/pass, you can create administrative user on pc to shutdown computer (admin rights of course).
Derik wrote:This script is to restart . is there might also be a shutdown and startup script ?

And may i do so without a password / login on a pc
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

I think i have to start here: [ is that correct?]
If you don't like put your user/pass, you can create administrative user on pc to shutdown computer (admin rights of course).


And then this:
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f

How do i fill this line correct?
example user is king and pass is day.
net rpc -S 192.168.1.xx -U king%day shutdown -t 1 -f

Or do i not need the % sign

Please will you tell me how i can do this correct.

And do i need to install samba and the smbclient?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
raxor
Posts: 8
Joined: Friday 17 April 2015 10:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by raxor »

Hi.
net rpc -S 192.168.1.xx -U king%day shutdown -t 1 -f
is correct, obviusly you need correct IP (change "xx" for your last ip digits)

And you need samba-common for "net rpc" command

In raspberry for example, (synology have samba-common )

Code: Select all

sudo apt-get install samba-common
ssh your domoticz

and test
net rpc -S 192.168.1.xx -U king%day shutdown -t 1 -f
Derik wrote:I think i have to start here: [ is that correct?]
If you don't like put your user/pass, you can create administrative user on pc to shutdown computer (admin rights of course).


And then this:
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f

How do i fill this line correct?
example user is king and pass is day.
net rpc -S 192.168.1.xx -U king%day shutdown -t 1 -f

Or do i not need the % sign

Please will you tell me how i can do this correct.

And do i need to install samba and the smbclient?
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

@ raxtor.
And without a password

Please help me with:
you can create administrative user on pc to shutdown computer
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
raxor
Posts: 8
Joined: Friday 17 April 2015 10:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by raxor »

Whitout a password, user non admin.

Create a new normal user without password

Windows key + R

lusrmgr.msc

(users folder right button --> create user)

untick (user change pass next logon) and tick (password never expires, and cannot change pass)

If your windows 7 are professional or ultimate (not for home edition)

Windows key + R

secpol.msc
Step-1.jpg
Step-1.jpg (56.22 KiB) Viewed 18235 times
Step-2.jpg
Step-2.jpg (42.51 KiB) Viewed 18235 times
Add your user to this policies

"force shutdown from remote ...."

and

"Shutdown the system"

reboot

try

Code: Select all

net rpc -S 192.168.1.xx -U king% shutdown -t 1 -f
If doesn't work add pasword for this user and search info to remove other permissions like create profiles or install apps (to no compromise this system).

Sorry my english :)

I'm att office, i test later in home.
Derik wrote:@ raxtor.
And without a password

Please help me with:
you can create administrative user on pc to shutdown computer
User avatar
groetg
Posts: 39
Joined: Tuesday 06 January 2015 20:41
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.4025
Location: Heerhugowaard, Holland
Contact:

Re: Shutdown Remote Windows PC

Post by groetg »

I use windows 10 beta and get this error when I give the following command through my rpi (putty):

pi@raspberrypi ~ $ net rpc -S 192.168.0.x -U user%password shutdown -t 1 -f
Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
Master: RPI Model 2B
Sub 1: RPI Model 2B
RFX transmitter/receiver 433 Mhz
13 KAKU units (3 window sensors, 1 door sensor, 7 light switches, 1 dusk sensor, 1 motion sensor)
4 IP cam
Meteostick
OTGW
P1 cable
Davis Vantage Pro weatherstation (incl. solar/UV)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

I did:
ScreenShot134.jpg
ScreenShot134.jpg (225.69 KiB) Viewed 17980 times
And:
ScreenShot133.jpg
ScreenShot133.jpg (22.13 KiB) Viewed 17980 times
And the RPi stuf...
chmod etc.

And i get:

Code: Select all

pi@raspberrypi ~ $ net rpc -S 192.168.5.5 -U Domoticz% shutdown -t 1 -f
Could not connect to server 192.168.5.5
Connection failed: NT_STATUS_ACCOUNT_RESTRICTION
Could not connect to server 192.168.5.5
Connection failed: NT_STATUS_ACCOUNT_RESTRICTION

The problem is the regfile... [ i guess ]
Where and how must ik make that?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

Edit...

I did not sleep a lot his night..... :D :D
Only 1 pc i can shutdown, i am very happy..... ;) ;) :oops: :P :mrgreen:

An other problem.
My laptop [ WiFi ] is not responding:

Code: Select all

pi@raspberrypi ~ $ net rpc -S 192.168.5.18 -U Domoticz%Domoticz shutdown -t 1 -fread_fd_with_timeout failed, read error = NT_STATUS_IO_TIMEOUT.
Receiving SMB: Server 192.168.5.18 stopped responding
Could not connect to server 192.168.5.18
Connection failed: NT_STATUS_BAD_NETWORK_NAME
read_fd_with_timeout failed, read error = NT_STATUS_IO_TIMEOUT.
Receiving SMB: Server 192.168.5.18 stopped responding
read_fd_with_timeout failed, read error = NT_STATUS_IO_TIMEOUT.
Receiving SMB: Server 192.168.5.18 stopped responding
Could not connect to server 192.168.5.18
Connection failed: NT_STATUS_BAD_NETWORK_NAME
Only what is bad network name?
Or Better, what is a good name?

Give it a other try:

Code: Select all

pi@raspberrypi ~ $ net rpc -S 192.168.5.18 -U Domoticz%Domoticz shutdown -t 1 -fCould not connect to server 192.168.5.18
Connection failed: NT_STATUS_UNSUCCESSFUL
Could not connect to server 192.168.5.18
Connection failed: NT_STATUS_UNSUCCESSFUL
What is here wrong?

Edit:
I make a setting in my WiFi adpater active, share the connection...
Try again:

Code: Select all

pi@raspberrypi ~ $ net rpc -S 192.168.5.18 -U Domoticz%Domoticz shutdown -t 1 -f
Could not connect to server 192.168.5.18
Connection failed: NT_STATUS_BAD_NETWORK_NAME
Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
And Again:

Code: Select all

pi@raspberrypi ~ $ net rpc -S 192.168.5.18 -U Domoticz%Domoticz shutdown -t 1 -f
Shutdown of remote machine succeeded
And i am Happy....
Only why respond the pc so slow?

Edit last time:

Not react:

Code: Select all

pi@raspberrypi ~ $  net rpc -S 192.168.5.18 -U Domoticz%Domoticz shutdown -t 1 -f
Could not connect to server 192.168.5.18
Connection failed: NT_STATUS_BAD_NETWORK_NAME
Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
I think the WiFi connection....?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Shutdown Remote Windows PC

Post by ThinkPad »

Why not use this: http://www.domotica-blog.nl/post/pc-net ... ia-zipabox

Seems quite easy.... Put the HTTP URL in a virtual switch.
I am not active on this forum anymore.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

ThinkPad wrote:Why not use this: http://www.domotica-blog.nl/post/pc-net ... ia-zipabox

Seems quite easy.... Put the HTTP URL in a virtual switch.
I tryed this.... :D
Only my boys turn off this program....: ;) :cry: :!:
An then..... :?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

Is it also possible on this way, to do this on a [ Android ] Tablet?
Or break the internet connection :-)


Edit:

When i dus this as slave to master switch...
My slave crashed..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
diggs
Posts: 3
Joined: Wednesday 06 May 2015 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by diggs »

Why not use this: http://www.domotica-blog.nl/post/pc-net ... ia-zipabox

Seems quite easy.... Put the HTTP URL in a virtual switch.
Just wondering if anyone was using this.

I tried to use it by putting in the "http://XXX.XXX.X.X:8000/?action=System.Shutdown"

It is in the "off action" of the switch but when I click it nothing happens.

If I paste the address into my browser, it shuts the machine down no problem.

DO I need to do anything with the http link in the off action part of the switch??
Attachments
turn-off-pc.jpg
turn-off-pc.jpg (38.01 KiB) Viewed 17765 times
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Shutdown Remote Windows PC

Post by Derik »

mmmm

I upgrade my pc to Windows 10...
Al the settings are the same like my first time...[ was working great until i did the upgrade ]

Only my pc is not going down.
Are there other setting that i need in Win10??

I was so happy... that i can remote shutdown my pc...

Help or so..

Thanks
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
jannl
Posts: 625
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Shutdown Remote Windows PC

Post by jannl »

Today I found out wake on lan is not really working for me. After the power returns to a PC, WOL does not work. Power is swtiched off to minimize electricity. PC takes about 30watts when switch off. Normally this works fine, only after a real power outage, the greenwave plug switches on, causing my PC to boot, which is basically only a problem on vacation.

So I wanted to try remote shutdown, so Domoticz could switch off the PC in case it is not switched on intentionally.
It seemed samba-common was already installed on my Pi, but 'net rpc' gives command not found.

Am I doing anything wrong? Any ideas?


Never mind: patience and google are my friends.
had to install samba-common-bin (after apt-get update && upgrade) and do some other windows 10 magic
User avatar
AlwinHummels
Posts: 7
Joined: Sunday 22 November 2015 20:25
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Dordrecht, The Netherlands
Contact:

Re: Shutdown Remote Windows PC

Post by AlwinHummels »

I tried to use the manual from raxor to shutdown my windows PC with a off button in Domoticz but nothing happens. when I use the command from the schript on shell it shuts down my PC as it should, so what did I miss?

I followed this step by step

I''ve the latest win 10 build (Insidder) and use Domoticz on my RPi.

Hope someone can help me.
smotx
Posts: 2
Joined: Tuesday 02 October 2018 10:56
Target OS: -
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by smotx »

raxor wrote: Friday 17 April 2015 18:57 Shutdown Windows computer (windows 7) from domoticz: using Synology or raspberry as a Domoticz server

INSTRUCCIONS FOR RASPBERRY

you need samba-common package

Code: Select all

sudo apt-get install samba-common

Code: Select all

nano /home/pi/domoticz/scripts/shutdown_PC.sh
content of script

Code: Select all

#!/bin/sh
#Shutdown Computer
# IP of computer and admin user needed
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f
(-f parameter force shutdown)

+x script (execution permission)

Code: Select all

chmod +x /home/pi/domoticz/scripts/shutdown_PC.sh
INSTRUCCIONS FOR SYNOLOGY

synology

Code: Select all

nano /volume1/@appstore/domoticz/scripts/shutdown_PC.sh
content of script

Code: Select all

#!/bin/sh
#Shutdown Computer
# IP of computer and admin user needed
net rpc -S 192.168.1.xx -U USER%PWD shutdown -t 1 -f
(-f parameter force shutdown)

+x script (execution permission)

Code: Select all

chmod +x /volume1/@appstore/domoticz/scripts/shutdown_PC.sh
IN WINDOWS (both cases, synology or raspberry)

To no disable windows UAC you can insert reg info to accept RPC commands

In windows create reg file. enablerpcshutdown.reg

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system]
"LocalAccountTokenFilterPolicy"=dword:00000001
- Execute to add to registry (DOUBLE CLICK),

Enable remote registry service

- Execute CMD witch admin rights (search cmd in start button, right button in cmd.exe execute with admin rights)

Code: Select all

sc config RemoteRegistry start= auto
sc start RemoteRegistry
- reboot windows

In Domoticz create virtual switch
Switch type: push off button
Assign to off action:
(RASPBERRY)
"script://home/pi/domoticz/scripts/shutdown_PC.sh"
(SYNOLOGY)
"script://volume1/@appstore/domoticz/scripts/shutdown_PC.sh"
Save
Good, this ok for me with W10 PC.

Thx a lot.
strasburger47
Posts: 1
Joined: Sunday 01 September 2019 0:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by strasburger47 »

Hello,
Instructions from raxor were brilliant and worked like a charm until update of windows 10 bringing possibility of login with PIN.
After that I tried many combinations and I was constantly receiving error after executing the command in console:
Connection failed: NT_STATUS_IO_TIMEOUT

It turned out I had to dig in windows defender firewall and tick all Remote Service Management and Remote Shutdown options to be allowed.
odorf
Posts: 4
Joined: Thursday 08 February 2018 14:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Shutdown Remote Windows PC

Post by odorf »

Hi

can You specify which settings You had to update?
Have the same issue with NT_STATUS_IO_TIMEOUT
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest