TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Having issues with TC launching a batch

    General Discussion
    2
    2
    11
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • StrahanS
      Strahan
      last edited by Strahan

      Hi!

      I'm having an annoying issue. I made a system I call HomeCenter which lets me manage smart home / home automation stuff. One of the functions is tracking laundry cycles, so when I start a load I press a button and a DB record gets entered then all the HomeCenter clients poll it every few minutes and if the time logged + duration for the cycle selected has passed, it plays an alarm. It's very loud and obnoxious so I don't miss it, lol. I wanted to be able to tell it to shut up though without using one of the HomeCenter PCs or tablets, because this morning I laid back down to snooze a bit and the alarm went off. It was a drying load, so it didn't matter if I went and handled it immediately so I just wanted HC to shut the hell up so I could sleep but as I didn't have my phone I had to get up and go to the kitchen to close out the alarm.

      So I decided I need to write a batch file that will delete the record from the DB via an Alexa voice command. So I fired up my TriggerCMD GUI editor and added a new record:

      Trigger: laundrydone
      Command: c:\misc\laundrydone.bat
      Off command: N/A
      Ground: foreground
      Voice: laundrydone
      Voice Reply: N/A
      Allow Parameters: false

      I then made the batch:

      @echo off
      sql homecenter "delete from activeitems where action = 8192" /u service.triggercmd.homecenter /p (pwd) /h lioth.mydomain.com /l laundryreset.log
      

      I opened the HomeCenter page and clicked Laundry, Started Wash Cycle - Clothes. I then fired up SQLyog and checked:

      SELECT * FROM activeitems;
      
      ID: 09d10a5d-ddb9-4eae-9e3e-17f6e6416cad
      action: 8192
      dtstarted: 2025-08-10 10:37:29
      flags: 0
      startedby: fe5303f8-0716-42cb-ade3-0a6023be87d9
      

      Cool. So I said Alexa, turn on laundrydone. She said OK. I do SELECT again, and I still see my row. So I open command and go to c:\misc and run laundryreset.bat. Do another SELECT and now there are no results. So the batch file works. Next I clicked start load again to obtain data then went to the TriggerCMD GUI editor, found laundrydone and clicked the play button. SELECT'd and I still have data. I do a very similar thing for my health tracking database. I can say "Alexa, turn on diet Pepsi" and it will use loghealth.bat to add that to my daily food log (I'm diabetic so I watch what I eat carefully). So I compared the two since TC has no issue with loghealth:

      C:\Misc>cacls loghealth.bat
      C:\Misc\loghealth.bat NT AUTHORITY\SYSTEM:(ID)F
                            BUILTIN\Administrators:(ID)F
                            BUILTIN\Users:(ID)R
                            MYDOMAIN\strahan:(ID)F
      
      
      C:\Misc>cacls laundryreset.bat
      C:\Misc\laundryreset.bat NT AUTHORITY\SYSTEM:(ID)F
                               BUILTIN\Administrators:(ID)F
                               BUILTIN\Users:(ID)R
                               MYDOMAIN\strahan:(ID)F
      

      Well, that looks fine. So I tried modifying the batch file:

      @echo off
      echo WTF is wrong with you>log.txt
      sql homecenter "delete from activeitems where action = 8192" /u service.triggercmd.homecenter /p (pwd) /h lioth.mydomain.com /l laundryreset.log
      

      Hit the play button in TC GUI, log.txt never appeared. What should I check next?

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @Strahan
        last edited by Russ

        @Strahan, I wonder if when the TC agent runs your batch file, the sql.exe file isn't in your PATH, so it doesn't run. The agent is probably running your batch file, which you've basically already proven with your loghealth.bat experiment.

        I like that you added another line to your laundryreset.bat file that writes something to a log file, but it's writing your log.txt file to the present working directory, which in the context of the TC agent is something like this:
        C:\Users\russ\AppData\Local\triggercmdagent\app-1.0.47\resources\app\src

        Assuming it is running your laundryreset script, you can probably fix this if you put the full path to your sql.exe file (and your log file) in the laundryreset.bat file, something like this:

        @echo off
        c:\full\path\sql.exe homecenter "delete from activeitems where action = 8192" /u service.triggercmd.homecenter /p (pwd) /h lioth.mydomain.com /l c:\logs\laundryreset.log
        echo From laundryreset.bat >> c:\logs\laundryreset.log
        dir >> c:\logs\laundryreset.log
        

        You'll want to remove the last 2 lines, especially the dir line, but I put it there because that can show you what the working directory is.

        Russell VanderMey

        1 Reply Last reply Reply Quote 0
        • First post
          Last post