Shutdown Remote Windows PC
Moderators: leecollings, remb0
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Shutdown Remote Windows PC
Hi,
Just wondered if anyone out there is doing this? I assume the best way would be some sort of script. I have done a bit of googling.. Found this:-
net rpc shutdown -I IPADDRESS -U USERNAME%PASSWORDP
Not tried it yet, any other ways? Example scripts?
Cheers
Simon
Just wondered if anyone out there is doing this? I assume the best way would be some sort of script. I have done a bit of googling.. Found this:-
net rpc shutdown -I IPADDRESS -U USERNAME%PASSWORDP
Not tried it yet, any other ways? Example scripts?
Cheers
Simon
- elythomaslumber
- Posts: 56
- Joined: Friday 12 July 2013 13:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: Solingen; Germany
- Contact:
Re: Shutdown Remote Windows PC
Hi Simon,
can't deliver a final solution but since some days I'm working on something similar.
I've a Synology NAS and would like to initiate a "poweroff" command after my Domoticz Raspy has done an automatic backup on the NAS.
Therefore I'm experimenting with this in a batch script on the Raspy:
or
This means I would like to open a SSH or Telnet session on the NAS remotly and then starting a command file stored on the NAS like:
With SSH it's hard since you've to handle certificates and I'm a noob on NAS and Linux. Maybe it's easier to use telnet but anyway it's hard for me to get it running. But maybe this gives you a starting point for your own experiments
Regards
Hardy
can't deliver a final solution but since some days I'm working on something similar.
I've a Synology NAS and would like to initiate a "poweroff" command after my Domoticz Raspy has done an automatic backup on the NAS.
Therefore I'm experimenting with this in a batch script on the Raspy:
Code: Select all
#!/bin/sh
get_poweroff_commands | telnet NAS-IP-Adress
Code: Select all
#!/bin/sh
get_poweroff_commands | ssh -t -t NAS-IP-Adress
Code: Select all
passwd="xxxxx"
echo ${passwd}
sleep 2
echo ${poweroff}
sleep 1
echo exit
Regards
Hardy
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
Hey,
Thanks for the info. Will look into it. Unfortunately my Raspberry has corrupted my SD card and looks like I have lost everything!!!
I'm hoping to access the data on the card. Just trying to find out what Domoticz files I need to save my beloved project! I have over 70 switches and 2 dozen scripts. Damn Linux! Lol
Cheers bud.
Thanks for the info. Will look into it. Unfortunately my Raspberry has corrupted my SD card and looks like I have lost everything!!!
I'm hoping to access the data on the card. Just trying to find out what Domoticz files I need to save my beloved project! I have over 70 switches and 2 dozen scripts. Damn Linux! Lol
Cheers bud.
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Shutdown Remote Windows PC
I don't know about windows, but with my Mac I needed to add the rsa fingerprint from my raspberry root to my Mac.
Now I can shutdown my Mac using a dummy switch in domoticz.
When I'm back home, I will post my script for you.
Now I can shutdown my Mac using a dummy switch in domoticz.
When I'm back home, I will post my script for you.
Op zoek naar een Domoticz Start Set?
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
Ah, that would be great.. Hope I can get it to work with a windows pc. I have managed to recover my data and am back up and running
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Shutdown Remote Windows PC
I don't think you can use this script for windows.
But here is my script anyway.
shutdown.sh
I think you need too look at something like this:
Got this from stackoverflow:
But here is my script anyway.
shutdown.sh
Code: Select all
#!/bin/bash
# connect too iMac
ssh -t -t [email protected] sudo shutdown -h now <<\EOF
PASSWORD
exit
EOF
Got this from stackoverflow:
Command to shutdown windows system from linux -:
$ net rpc -S <ip address> -U <username>%<password> shutdown -t 1 -f
This command can be issued from bash or even set in cron job to shutdown the computer at a specific time and this command is shipped with many distros by default.
Op zoek naar een Domoticz Start Set?
- Keptenkurk
- Posts: 103
- Joined: Wednesday 21 August 2013 17:24
- Target OS: -
- Domoticz version:
- Location: Waalre, The Netherlands
- Contact:
Re: Shutdown Remote Windows PC
At work we use PsTools, a commandline tool, to do all kinds of fancy things on a 1000 remote windows clients.
Shutting down is one of the options but there is much more like killing and starting processes etc.
/paul
Shutting down is one of the options but there is much more like killing and starting processes etc.
/paul
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
Hi,
Thanks everyone for your ideas and suggestions. I think I have PStools on my windows PC, I use squeezeboxes at home and an addon I have installed required me to install it. Do you know how to trigger force shutdown via PStools in a script from linux?
I'll try the one above later, thanks for that!
Thanks everyone for your ideas and suggestions. I think I have PStools on my windows PC, I use squeezeboxes at home and an addon I have installed required me to install it. Do you know how to trigger force shutdown via PStools in a script from linux?
I'll try the one above later, thanks for that!
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
Couldn't get the above script to work... hmmmmm
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Shutdown Remote Windows PC
Sorry. Can't help you to test it. Don't own a windows PC.
Op zoek naar een Domoticz Start Set?
- Keptenkurk
- Posts: 103
- Joined: Wednesday 21 August 2013 17:24
- Target OS: -
- Domoticz version:
- Location: Waalre, The Netherlands
- Contact:
Re: Shutdown Remote Windows PC
Sorry Simon, the PSTools is a windows <--> windows thing, didn't read your post carefully enough
To use mbliek's proposed "net rpc" you will need to have samba installed first.
pi@raspberrypi~$ sudo apt-get install samba
pi@raspberrypi~$ sudo apt-get install samba-common-bin
pi@raspberrypi~$ sudo apt-get install smbclient
after which you shoul be able to:
net rpc shutdown -I server_ip -U username
(from: http://www.raspberrypi.org/phpBB3/viewt ... 37&t=56192)
ow .. and i might add this disclaimer: I've never done this either - just reading the same stuff as you...
To use mbliek's proposed "net rpc" you will need to have samba installed first.
pi@raspberrypi~$ sudo apt-get install samba
pi@raspberrypi~$ sudo apt-get install samba-common-bin
pi@raspberrypi~$ sudo apt-get install smbclient
after which you shoul be able to:
net rpc shutdown -I server_ip -U username
(from: http://www.raspberrypi.org/phpBB3/viewt ... 37&t=56192)
ow .. and i might add this disclaimer: I've never done this either - just reading the same stuff as you...
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Shutdown Remote Windows PC
Cheers Keptenkurk! Will try it out tomorrow
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Shutdown Remote Windows PC
I installed samba and I get the same error which is line 3: $: command not found. Hmmm
Edit:- I have edited my bash script to:-
net rpc shutdown -I server_ip -U username (with my details)
Edit 2:- When running from root I get this
root@raspberrypi:~# net rpc shutdown -I 192.168.1.27 -U [email protected]
Enter [email protected]'s password:
Could not connect to server 192.168.1.27
Connection failed: NT_STATUS_BAD_NETWORK_NAME
Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
Edit:- I have edited my bash script to:-
net rpc shutdown -I server_ip -U username (with my details)
Edit 2:- When running from root I get this
root@raspberrypi:~# net rpc shutdown -I 192.168.1.27 -U [email protected]
Enter [email protected]'s password:
Could not connect to server 192.168.1.27
Connection failed: NT_STATUS_BAD_NETWORK_NAME
Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
The problem appears to be my Windows PC itself, command looks good. I'll let you know if I get it to work..
-
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Shutdown Remote Windows PC
Sorted.
Appears to be working at the mo, next thing to do is to ping the computers to see if they are on..
Thanks everyone.
If anybody wants to use this and is struggling to get it to work, post here and I'll make a quick tut.
Cheers
Appears to be working at the mo, next thing to do is to ping the computers to see if they are on..
Thanks everyone.
If anybody wants to use this and is struggling to get it to work, post here and I'll make a quick tut.
Cheers
-
- Posts: 1
- Joined: Sunday 08 March 2015 12:06
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Shutdown Remote Windows PC
Hello,
I'm able to shut down my windows computer from command line by typing net rpc -S 192.168.0.14 -U Admin%password shutdown -t 1 -f
I've made a script using nano, it looks like this:
I've chmod 775 the file
I've named the script Shutdown_PC
In domoticz i've made a virtual button with in the off action field => script://Shutdown_PC
When i push the button nothing happens.
What i'm I doing wrong?
I'm able to shut down my windows computer from command line by typing net rpc -S 192.168.0.14 -U Admin%password shutdown -t 1 -f
I've made a script using nano, it looks like this:
Code: Select all
#!/bin/bash
#Shutdown Computer
net rpc -S 192.168.0.14 -U Admin%password shutdown -t 1 -f
I've named the script Shutdown_PC
In domoticz i've made a virtual button with in the off action field => script://Shutdown_PC
When i push the button nothing happens.
What i'm I doing wrong?
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Shutdown Remote Windows PC
You need to use the full path
script:///home/pi/domoticz/scripts/Shutdown_PC.sh
Note the 3 time /
script:///home/pi/domoticz/scripts/Shutdown_PC.sh
Note the 3 time /
Op zoek naar een Domoticz Start Set?
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Shutdown Remote Windows PC
is the third / needed ?mbliek wrote:You need to use the full path
script:///home/pi/domoticz/scripts/Shutdown_PC.sh
Note the 3 time /
I got it to work with just two.
//Daniel
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
- mbliek
- Posts: 194
- Joined: Friday 12 July 2013 14:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: the Netherlands
- Contact:
Re: Shutdown Remote Windows PC
It was needed before. Maybe it changed...
Op zoek naar een Domoticz Start Set?
-
- Posts: 32
- Joined: Sunday 08 March 2015 13:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.4739
- Contact:
Re: Shutdown Remote Windows PC
I have the same problem with the script. But in the Log of Domoticz i see:
Error: Error executing script command (/volume1/@appstore/domoticz/scripts/lua/shutdown_pc.lua). returned: 32512
When i run the script with a normal ssh connection to my Synology it works fine. Script is chmod 775.
What does error 32512 mean?
Peter
Error: Error executing script command (/volume1/@appstore/domoticz/scripts/lua/shutdown_pc.lua). returned: 32512
When i run the script with a normal ssh connection to my Synology it works fine. Script is chmod 775.
What does error 32512 mean?
Peter
RaspberryPI
ZWave
RFXtrx433E
ZWave
RFXtrx433E
Who is online
Users browsing this forum: No registered users and 1 guest