How do i restart openHAB by rule?

I am running openhab2 on Windows 10 as a service
My question: How do I write the rule that will allow me to restart openhab by sending a message from the telegram?

rule "reboot system"

   Item telegram_telegramBot_Telegram_Bot_lastMessageText changed to reboot openhab

This should help: [SOLVED] Reboot or shutdown raspberry with rule

i run openhab on windows, not on raspberry

Ooops, sorry - I missed that part.
Nevertheless you may try executeCommandLine together with a windows command to restart the computer. Command to be used is explained here:

I would assume that this one ( Remote Shutdown PC Using EXEC on Windows PC OpenHAB ) also should work although it is being executed as a command on a remote computer.

1 Like

If I run this command it works fine
executeCommandLine ("shutdown / r", 100)
But I want to run a bat file and not restart the computer so I try to run the following command but it does not work, the file does not open
executeCommandLine ("C:\Users\razse\Desktop\reboot.bat", 100)

Try to escape the back-slashes: C:\Users\razse\Desktop\reboot.bat
There is a space between executeCommandLine and parenthesis. Is that just here or also in your rule ?

it not working
this is my rule:

rule "reboot system"


   Item reboot_system changed to ON




Did you try this:


still not working

  • do you see any message in the openhab.log / events.log that gives a hint ?
  • add a lines like this surrounding the execute command
logInfo( "MyRule", "Before ...." )
logInfo( "MyRule", "After ...." )
  • in case you see the messages but the batch file is not executed you can conclude that the rule itself is ok
  • add something to your batch file that at the beginning creates a file in e.g. c:\temp; if that one is available your file is being executed but there might be permssion issue with the command that you want to execute from within the batch file; if the file is not created in c:\temp then there is a permission issue with the batch file or it cannot be found
  • there should be a scripts directory next to the rules directory you may place the batch file in that directory to get around permission problems accessing a users directory

before and after the executeCommandLine

This work for windows

thanks but this rule restart my pc i want to restart only openhab service

Stop/Start a bundle

Restart a bundle

But your title is

How do i reboot system by rule?

Which to most people means how do you reboot the PC. I have now edited your title to make it clearer.

Thanks but these do not work either
Something strange because he responds to this command

executeCommandLine C:\\Windows\\System32\\shutdown.exe@@/r@@/t@@0

but he does not respond to the rest

the remaining means: bundle:start, bundle:stop, bundle:restart ?
These commands require a number as argument. The number will be different on each individual system and need to be detected during runtime. So the 293 is the id of a specific bundle on your system as the same bundle has a different id on my system.

You may try if this works as expected:


If that does not work you may need to run

net stop "openHAB2"


net start openHAB2

For these commands the openhab user needs elevated privileges.

Other alternatives are mentioned ( windows ps tools ) here:

I changed to the location where the correct openhab2 is installed on my computer
But does not work
And how do I find the bundle: restart / stop / start id?
I wrote in console
What is it called in the list?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.