Windows PC remote control (Shutdown, ...)

Hello,

i’m using Powershell Server on my Windows 10 PC and the EXEC binding. The solution is not perfect, but it works for me.

Here is an example of 4 commands that i send from OH to start/stop Steam or Plex application.

Rules:

rule "HTPC StartSteam"
when
Item HTPC_StartSteam received command
then 
var String response = executeCommandLine("/usr/bin/sshpass -p '' ssh -o StrictHostKeyChecking=no username@pc start-process steam.bat", 2000)
logInfo("HTPC_StartSteam", response)
end

rule "HTPC KillSteam"
when
Item HTPC_KillSteam received command
then 
var String response = executeCommandLine("/usr/bin/sshpass -p '' ssh -o StrictHostKeyChecking=no username@pc kill -processname Steam", 2000)
logInfo("HTPC_KillSteam", response)
end
 
rule "HTPC StartPlex"
when
Item HTPC_StartPlex received command
then 
var String response = executeCommandLine("/usr/bin/sshpass -p '' ssh -o StrictHostKeyChecking=no username@pc start-process plex.bat", 2000)
logInfo("HTPC_StartPlex", response)
end

rule "HTPC KillPlex"
when
Item HTPC_KillPlex received command
then 
var String response = executeCommandLine("/usr/bin/sshpass -p '' ssh -o StrictHostKeyChecking=no username@pc kill -processname 'Plex Home Theater'", 2000)
logInfo("HTPC_KillPlex", response)
end

the start processes are handled by a batch file and PSEXEC (i put both in the user documents folder at the WIN 10 machine)

Content of plex.bat

psexec -i "c:\program files (x86)\plex home theater\plex home theater.exe"

When I start processes directly throw the executeCommandLine, the processes are starting invisble in the background and not under the logged in user.

My WIN PC has no password and the PowershellServer runs not as service.

Hope this helps.

1 Like