Run External .bat FIle

  • 75 Views
  • Last Post 30 October 2013
Axial-User posted this 29 October 2013

Hello all,

I am trying to move over from my Homeseer system to new software. One thing that I need is to be able to run an external program (.bat file) when something is triggered. Basically what I am doing is using the linphone daemon with asterisk to do announcements through my VOIP phones that I have. I already do this with Homeseer and it works great. I have different page groups setup so that I can target the announcement to all of the phones or only the ones that need the announcement.

So how would I go about doing this? I didnt find anything other than using a script but I dont know c# just yet and my trial is running out quickly. Could someone give me a simple script that I could use to test this with?

Thanks for any help!

Order By: Standard | Newest | Votes
Ryan-Scott posted this 29 October 2013

Hello all,

I am trying to move over from my Homeseer system to new software. One thing that I need is to be able to run an external program (.bat file) when something is triggered. Basically what I am doing is using the linphone daemon with asterisk to do announcements through my VOIP phones that I have. I already do this with Homeseer and it works great. I have different page groups setup so that I can target the announcement to all of the phones or only the ones that need the announcement.

So how would I go about doing this? I didnt find anything other than using a script but I dont know c# just yet and my trial is running out quickly. Could someone give me a simple script that I could use to test this with?

Thanks for any help!


Here's a response from another user on how to setup and run a .bat file. The only thing I might add is that it might be easier to use a scene post/pre script instead of a rule if it fits into your scenario.

Axial-User posted this 29 October 2013



Here's a response from another user on how to setup and run a .bat file. The only thing I might add is that it might be easier to use a scene post/pre script instead of a rule if it fits into your scenario.



That worked perfect as far as incontrol is concerned but its not running what is inside the .bat file. The only part that is working is the one echo I put in to make sure it was running. Here is the bat file and the resulting log.txt it created:

C:\Progra~2\Linphone\bin\linphonecsh dial "213@172.16.30.12" >> c:\scripts\log.txt

c:\sounder c:\pjsua\hello-world.wav >> c:\scripts\log.txt

C:\Progra~2\Linphone\bin\linphonecsh generic terminate >> c:\scripts\log.txt

echo it ran >> c:\scripts\log.txt

log.txt:

it ran

And here is the log it generates when it is run from the command line by just doubleclicking the bat file from explorer:

Establishing call id to , assigned id 15
Call 15 to in progress.
Call 15 with ended (No error).
it ran

Is there a certain way to setup the .bat file itself? Rules, permissions?

Ryan-Scott posted this 29 October 2013



That worked perfect as far as incontrol is concerned but its not running what is inside the .bat file. The only part that is working is the one echo I put in to make sure it was running. Here is the bat file and the resulting log.txt it created:

C:\Progra~2\Linphone\bin\linphonecsh dial "213@172.16.30.12" >> c:\scripts\log.txt

c:\sounder c:\pjsua\hello-world.wav >> c:\scripts\log.txt

C:\Progra~2\Linphone\bin\linphonecsh generic terminate >> c:\scripts\log.txt

echo it ran >> c:\scripts\log.txt

log.txt:

it ran

And here is the log it generates when it is run from the command line by just doubleclicking the bat file from explorer:

Establishing call id to , assigned id 15
Call 15 to in progress.
Call 15 with ended (No error).
it ran

Is there a certain way to setup the .bat file itself? Rules, permissions?


I'm not sure why your other programs wouldn't run... there doesn't seem to be an apparent reason. I would suggest that it was a path problem since the script is being executed from the InControl folder, however it appears that you are using absolute paths... what's "c:\sounder" a reference to? Is there any chance that the programs themselves require you to "cd" to their folder or that they need absolute paths as well?

Also, InControl executes these bat files from a service running as an admin. If you are running as a service (tools/options), then it's additionally running from the service space, so that may make a difference in permissions as well.

Here are some random things to try - no idea if they'll work, but it would be an interesting test.

Create a second batch file that does all your heavy lifting; then in your bat file that InControl runs, have it execute your second one by calling "start secondFile.bat" and see if it makes a difference. Alternatively, try using a "call" command in place of start.

Axial-User posted this 30 October 2013

This morning I had a chance to sit down and look at this again. It's a problem with permissions it seems. I was running incontrol as a service using a system account as you mentioned in your reply so that got me on the right track. I changed the service to login as the user the PC was starting up as and it worked just fine. The only problem I had after that was the bat file firing off each command one right after the other without waiting for the others to complete so I had to change to using the start command for each one with the /wait switch on.

Sounder is just a very simple media player that runs from the commandline, plays the file you give it, then exits...real clean for quick sound effects without having some large media player to load and do the job. Playing the wav file was just a test, it will actually get replaced with a small commandline tts frontend to do announcements (although I might just save my static announcements as wav files)

Thanks again for the help!!

Close