Exec Binding strange behavior

I am running OH3 on Win 10 as a service. I wold like to restart OH with a simple script.
@echo off
net stop openHAB
timeout 20
net start openHAB
To gain admin right I used the program “bat to exe” witch has an option to add admin rights.
I added the resulting exe and the commands in the script to the whitelist.
It does not work!
To find the reason I tried to start any program through the exec binding. It is not possible!
The only thing that works are echo commands in a script which I write in a log file.
This command: Thing exec:command:oh_reboot [command=“shutdown /r”, interval=0, autorun=false]
does not work.
OH behaves completely different, wenn started as a service. Then I can start exe files, bat files net commands.
Any idea what could be the reason or how to fix this problem?

It’s not the exec binding, it’s not openHAB, its Windows service restrictions.
I don’t know of any “fix”

So its a known problem. Is it possible to document this in the exec binding? This could save many hours!

By using MQTT and winthing I could start the exe file.
I wounder why winthing can start a script or exe file and the Exec binding not. This seams not logic to me.

Is winthing running as a service?

Winthing is not running as as service. So this seams to be the problem. That is probably the reason why IOTLink can’t run scripts either.

I have found a solution: You have to turn of the UAC. I did it trough the Local group policy editor (gpedit) option 3 in the following article: How to Disable UAC in Windows 10? Here Are Four Simple Ways! - MiniTool
Windows service restriction are off!

To avoid deactivation of the UAC you can use the program runElevated https://robotronic.net/elevatede.html
You need two patch files. Lets call them test.bat and start_test.bat.
Start the start_test.bat from OH like this:


The start_test.bat starts the test.bat elevated

start C:\openHAB\RunElevated.exe C:\openHAB\test.bat

The test.bat looks like this:

net stop openhab
timeout 60
net start openhab

A powershell script can do the same without timout and the command restart-service. You have to create an exe with the program ps12exe and start the exe with the start_test.bat