Exec issues after update to 2.4

Hi all
was on OH 2.2 and was using exec to control my PC most of the commands are migrated with no issues
but i am unable to run URLs, for example

c:\Program Files (x86)\Google\Chrome\Application\chrome.exe https://www.youtube.com/watch?v=U9BwWKXjVaI

when i run this on windows run i am able to run with no issues, also most of the other exec commands are still working , i am getting below error from OH logs

22:32:34.248 [ESH-thingHandler-72] ERROR org.openhab.binding.exec.handler.ExecHandler - An exception occurred while executing 'c:\Program Files (x86)\Google\Chrome\Application\chrome.exe https://www.youtube.com/watch?v=U9BwWKXjVaI' : 'Cannot run program "c:\Program": CreateProcess error=2, The system cannot find the file specified'


found a work around

  1. download nircmd (you can find the link below)
  2. put on C drive (for the exmpale)
  3. use below command to run URL
shexec [operation] [filename]

Opens or Prints a filename according to the definition of the file extension in the Registry. For example: a filename with .doc extension will be opened with MS-Word, a filename with .html extension will be opened with your default browser. If you specify a valid web site address, the Web site will be opened in your default browser. the [operation] parameter can be “open” or “print”.
shexec “open” “c:\my documents\abc.doc”
shexec “print” “d:\files\1.pdf”
shexec “open” “http://www.nirsoft.net

so it will look like this in the thing def
nircmd.exe shexec “open” “http://www.nirsoft.net

1 Like

I’m glad you found a work around. I think it would have worked though had you use the @@ in place of spaces as described in the Exec binding readme.


You also might need to escape the backslashes like I did above.

1 Like

i did this also not sure i got the DOC right
is this looks ok? still not wokring


not sure why copy paste as dropped some \ but i did as you pasted above,
not working ,but also i am not getting any errors so somthing did change…

As far as I know nothing has changed. I don’t have any other ideas. I don’t use Exec much and never have used it on Windows.

1 Like

Example that works for me under Win7

results=executeCommandLine("C:\\openhab2\\conf\\scripts\\snapshuffle.bat", 10000)

Maybe you could replace Program Files (x86) with the dos shortname PROGRA~2 or something.

I think you need the PATH system variable to include your path, but I’m sure it already should.

thanks i will reamin with the workaround its working cool and links are the only thing i am missing

thanks for all the help, i had sys vars defined and all was working not sure why link stoped