[SOLVED] Exec binding on Windows 8

I would like to launch an executable file (.exe) on Windows 8, from OpenHAB, when an item (in my case, “nbState”) gets a particular value (in my case, 5).

This is my item configuration:

Number nbState {exec=">[5:START “MyProgram” “C:\Path\MyProgram.exe”]"}

But it doesn’t work.

Does the exec binding work on Windows?
If yes, what is the right syntax?


I use the exec on M$-Windows 10 to shutdown computers; this is from my items configuration; I hope it helps:

Switch networkGamePC "Spiele PC" <computer> (gNetwork, gHomeEGTV) { nh="GAME-PC:139", wol="", exec=">[ON:] >[OFF:shutdown -s -m \\\\GAME-PC -t 0 -f]" }

with kind regards,

I guess shutdown is a windows command.
Do you have a rule where you launch your own .exe file?

I use START because I need my executable program to remain being executed. It is not a program that does one particular thing and closes. It needs to be continuosly running.

I am trying to find the difference between your working configuration and mine…

I don’t think I need to change the item to a Switch item.
I guess Number it’s ok, isn’t it?

Mhhh …sorry; not an expert either. I use autostart for things that need to run always (e.g. TTS utility) and windows scheduled jobs to call things I need to run e.g. every 5 minutes (update calendar items from google calendar). The closest I found on my system is a place where I call a .bat file (I did add the path to the environment variable of windows):

Switch squeezeTVPower "TV" <squeeze> (gSqueezeTV, gHomeEGTV, gMusikPower) { squeeze="TV:power", exec="ON:squeeze.bat" }

Dont’t know about the number …try the switch as a first (as I know that works); then once that’s sorted out you may change/verify that is works with a number as well.

kind regards,

I have tried many combinations:

-change the .exe to a .bat file
-keep the .exe syntax
-add the folder to system path
-change the item from Number to Switch.
-try the new syntax {exec=">[ON:MyProgram.bat]"}
-try the old syntax {exec=“ON:MyProgram.bat”}

Nothing works.

Are you using Windows 8.1?
I don’t understand what I am doing wrong…

I use windows 10; sorry I’ve no idea why it is not working.

I assume you have the “org.openhab.binding.exec-1.8.0.jar” present in your add-on folder?

Try to start OH with debug configuration; do you see log entries when you try trigger the switch?

Now it works (although it took me a while…)

It seems that:

1- System path change wasn’t being taken into account by OpenHAB
2- Antivirus blocked the execution of the program (silently!!)
3- The program was executed from the OpenHAB directory, and when it was launched, it didn’t find the proper config file.


1- Restart the computer :slight_smile:
2- Add an exception in the Antivirus
3- Create a .bat file that goes to the right directory, and then launches the program.

Problem solved.

Hallo sercasyr,
Could you please Post the example that works on Your Computer, item and exec Code, also where the File is saved?

Greetings Michael

This is what I did:

Add this to the items file:
Switch swExec (grExec) {exec=">[ON:MyApp.bat] >[OFF:taskkill /IM MyApp.exe /T /F]"}

The MyApp.bat is located in this folder: "C:\MyDir"
This folder is added to the system path (Control Panel -> System -> Environment Variables)

The content of MyApp.bat is:

CD MyDir
START MyApp.exe

Hope it helps…

Thanks for your fast replay:

i placed my test.bat to the openhab directory:


and for the test i turn this switch on (in the items file)
but still not working, i also use windows 8. maybe you got some more idea?

Switch swExec {exec=">[ON:test.bat] >[OFF:]"}

what exactly you did at this step:

"This folder is added to the system path (Control Panel -> System -> Environment Variables)"
Thank you