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

    How to use Off Command

    Instructions
    11
    30
    56.0k
    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.
    • Emanoel Matheus lima da silva souzaE
      Emanoel Matheus lima da silva souza
      last edited by

      fala portuges

      1 Reply Last reply Reply Quote 0
      • XanderX
        Xander @Russ
        last edited by Xander

        @Russ I'm trying to setup an on/off command for some services. The PC is x86 so I'm just editing the JSON file.

        Here's the line inside the JSON:
        {"trigger":"Remote","command":"C:\Users\STICK10\Documents\SC on.bat","offCommand":"C:\Users\STICK10\Documents\SC off.bat","ground":"foreground","voice":"Remote","voiceReply":"Okay","allowParams":"true" },

        When I try to trigger it, it's only running the SC ON batch file, not the OFF. What's my error? Or do I need to set these as two different commands altogether?

        Inside TCMD's cmd window:
        { trigger: 'Remote',
        id: '____',
        params: 'on' }
        Running trigger: Remote Command: C:\Users\STICK10\Documents\SC on.bat
        Reported: Command Ran

        { trigger: 'Remote',
        id: '____',
        params: 'off' }
        Running trigger: Remote Command: C:\Users\STICK10\Documents\SC on.bat
        Reported: Command Ran

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

          @Xander, I just tried sending "off" with this commands.json entry and it worked for me.

           {
            "trigger": "Remote",
            "command": "C:\\Users\\STICK10\\Documents\\SC on.bat",
            "offCommand": "C:\\Users\\STICK10\\Documents\\SC off.bat",
            "ground": "foreground",
            "voice": "",
            "voiceReply": "",
            "allowParams": "true"
           }
          

          This was my output:

          { trigger: 'Remote', id: '___', params: 'off' }
          Running trigger: Remote  Command: C:\Users\STICK10\Documents\SC off.bat
          Reported: Command Ran
          

          So maybe you're using a old version of the agent from before I added the logic to use the offCommand field. I know you're running in on an x86 Windows box, so you're not running the normal agent. You can probably just update the agent.js file.

          Russell VanderMey

          XanderX 1 Reply Last reply Reply Quote 0
          • XanderX
            Xander @Russ
            last edited by Xander

            @Russ That's probably it. The agent.js has a date stamp of Nov 2017. Closed tcmd, updated from your link (old was 23kb, new is 348kb. Quite the diff!)

            But, on starting the batch file, I get an "unexpected token" error. It also overwrote my .json file but it was mostly the line above so I'll redo it if I need to. Swapped the old .js back and it runs so something is amiss.

            SyntaxError: Unexpected token <
                at createScript (vm.js:80:10)
                at Object.runInThisContext (vm.js:139:10)
                at Module._compile (module.js:599:28)
                at Object.Module._extensions..js (module.js:646:10)
                at Module.load (module.js:554:32)
                at tryModuleLoad (module.js:497:12)
                at Function.Module._load (module.js:489:3)
                at Function.Module.runMain (module.js:676:10)
                at startup (bootstrap_node.js:187:16)
                at bootstrap_node.js:608:3
            
            RussR 1 Reply Last reply Reply Quote 0
            • RussR
              Russ @Xander
              last edited by

              @Xander, the latest version of agent.js is about 23k. Maybe try again to download it? Or look at the one you have maybe there's a clue what's wrong with it. It shouldn't be that big.

              Russell VanderMey

              XanderX 1 Reply Last reply Reply Quote 0
              • XanderX
                Xander @Russ
                last edited by

                @Russ D'oh. The link here showed it went to ...node.js so I downloaded from here but now it's clear that it was a page about it so I've DL'd it properly 🤦🏻‍♂️
                That's back up and running.

                Question, though. I switched the command to use SCHTASKS to run a job of the same batch files to circumvent any UAC issues but SCoff doesn't work in either bat or task form. The cmd window -says- it's being called but no window is called. Any ideas?

                [
                   {"trigger":"Users","command":"schtasks.exe /run /tn users","ground":"foreground","voice":"users"},
                   {"trigger":"Connect","command":"schtasks.exe /run /tn SCon","ground":"background","voice":"connect"},
                   {"trigger":"Disconnect","command":"schtasks.exe /run /tn SCoff","ground":"background","voice":"disconnect"},
                   {"trigger":"Remote","command":"schtasks.exe /run /tn SCon","offCommand":"schtasks.exe /run /tn SCoff","ground":"foreground","voice":"Remote","voiceReply":"Okay","allowParams":"true" },
                   {"trigger":"Reboot","command":"shutdown /r /t 10","ground":"foreground","voice":"reboot"}
                ]
                

                In case I would need them as separate commands, I created the Connect/Disconnect commands which I think are fine but they don't show in the TCMD trigger page at all.

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

                  @Xander, I think the reason those 2 commands don't show up in your account is you've set them as "background" commands and you're not running the background agent. You'll need to run the background agent or switch them to foreground.

                  You wrote, "SCoff doesn't work in either bat or task form." Does it work if you run it manually from a cmd prompt? You might want to put something in your .bat file that logs to a file so you know for sure whether the .bat is running. I just wonder if it's running but it's getting an error that you can't see. Something like this would at least confirm whether it's running or not:

                  echo SCoff ran >> c:\logs\scoff.log
                  

                  Russell VanderMey

                  XanderX 1 Reply Last reply Reply Quote 0
                  • XanderX
                    Xander @Russ
                    last edited by

                    @Russ Sorry for the delayed reply; crazy week.

                    Background was the problem on the one part.
                    On the other, for some weird reason, Task Scheduler was renaming the actual .job from "SCoff" to "SC off" so that the path was wrong. Once I spotted that, I got it working.

                    Just to check - I've been running the x86 version of TCMD on that PC for...years? Other than the updated .js, there's no newer version? The main DL is x64.

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

                      @Xander, there's no official x86 TRIGGERcmd agent version. If you updated agent.js, you've got the latest functionality.

                      Russell VanderMey

                      1 Reply Last reply Reply Quote 1
                      • YoniY
                        Yoni @Russ
                        last edited by

                        @Russ May be worth updating the instructions to indicate that "on" and "off" are case sensitive if you want it to automatically choose between the On and Off commands. (Alternatively ignore case for on and off to choose between on command and off command)
                        e.g. I used IFTTT and sent "ON" or "OFF" as parameters, and it just sent those as arguments to my ON command.
                        Once I fixed it to "on" and "off" it properly instead chose between the commands instead of using them as arguments.

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

                          @Yoni, thanks for letting me know. I'll make it case-insensitive in the next version.

                          Russell VanderMey

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