Home Assistant integrations that allow you to run command on remote Windows PC, for example hibernate, that can't do net rpc.
Component create and run service on remote PC, that execute command. On end of execution service will delete. More info here.
The user must be an administarator. If on remote PC turned on UAC, you need to do one change in registry. Find key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
change value of LocalAccountTokenFilterPolicy to dword:00000001
configuration.yaml:
psexec:
scripts.yaml template:
script:
name_of_your_script:
sequence:
- service: psexec.exec
data:
encrypt: false
host: 192.168.1.10 # ip of your PC
username: user # user name
password: password # password for user
command: cmd.exe /c echo Hello World > c:\out.txt # this command create out.txt on root of C:\You can wake and hibernate your PC remotely. You will this and Wake on Lan integration.
In scripts.yaml add :
script:
desktop_remote_hibernate:
sequence:
- service: psexec.exec
data:
encrypt: false
host: 192.168.1.10 # ip of your PC
username: user # user name
password: password # password for user
command: cmd.exe /c start /b shutdown.exe /h # this command will hibernate PCswitch:
- platform: wake_on_lan
name: Switch name
mac: AB:CD:EF:GH:IK:LM
host: 192.168.1.10
turn_off:
- service: script.desktop_remote_hibernateThis switch will be wake your PC on toggle ON and hibernate on toggle OFF.
Manually copy psexec folder from latest release to custom_components folder in your config folder.
Original posted by AlexxIT (source). I'm just create repository.