Page 1 of 1

Windows Batch, make use of taskschedular in domoticz

Posted: Saturday 01 February 2025 21:46
by zicht
Sometimes i use os.execute command to do things and when it hangs, domoticz slows down & gives an error running >10 secs.
Thats unwanted and after some thinking i have a simple solution :

Create in the domoticz dir a batchfile named "run_command.bat"
Create in taskschedular a task named "z__run_command"
  • this task executes the "run_command.bat"
  • this task has no trigger (it will be triggered from the script below)

Code: Select all

function uitvoeren(tedoen)
    local f = io.open("run_command.bat", "w") f:write(tedoen) f:close()
    os.execute('powershell.exe Start-ScheduledTask -TaskName "z__run_command"')
end
Call this function anywhere in your script with "uitvoeren(<your os command>)"

The script above writes your command to the batch file and starts the scheduled task without almost any wait. (Powershell is very fast.)
Taskschedular will run the batch file in another process, no influence on domoticz.

Be aware there is no feedback and domoticz does not wait to finisch, it continues normally, thus no dependencies on the result are posible.
With a trick (redirect console to a txt file) it would be possible to get the result (by reading the txt file) but then you have to test it later as domoticz has allready seconds continued.

Re: Windows Batch, make use of taskschedular in domoticz

Posted: Saturday 01 February 2025 22:01
by waltervl
What about using the dzvents asynchronous domoticz.executeShellCommand('some shell command')
function?

https://wiki.domoticz.com/DzVents:_next ... _execution

Re: Windows Batch, make use of taskschedular in domoticz

Posted: Tuesday 04 February 2025 17:48
by zicht
waltervl wrote: Saturday 01 February 2025 22:01 What about using the dzvents asynchronous domoticz.executeShellCommand('some shell command')
function?

https://wiki.domoticz.com/DzVents:_next ... _execution
missed that one ! Thanks : that looks a lot better ...