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

    Questions

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 1.5k Views 1 Watching
    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.
    • Tony JiménezT Offline
      Tony Jiménez
      last edited by

      Good, I have two questions for you,
      1- How can I run a script as an administrator from trigger cmd? What happens is that when I run it as an administrator myself I do not give me errors and when I do it with trigger cmd an application does not close because an access error deneged

      2- Therefore, I would like to know how I can run a script with trigger cmd but that looks on the screen the CMD window to see what is the error in the following script's developing, since I currently realize that I do not know that I do not know It develops one or two steps of it, I am new to all this and it helps me a lot to read the error codes to look for them on Google.

      By the way, use Windows.

      Thank you.

      RussR 1 Reply Last reply Reply Quote 0
      • RussR Online
        Russ @Tony Jiménez
        last edited by Russ

        @Tony-Jiménez, here's one way to run elevated commands to run "As administrator" via TRIGGERcmd:

        Open Task Scheduler and create a task called "AdminScript" like this:

        4b8695a2-4c07-40c6-a789-f5f4bd0e3e2e-image.png

        This is what the Action settings look like:

        945218d8-4c07-4e44-b348-e6c1ce901911-image.png

        On the General Tab, click this "Run with highest privileges" checkbox. That basically tells it to run "As administrator", aka elevated.

        4681b4b0-33fd-4fa9-8171-aa836f49506e-image.png

        Make your TRIGGERcmd command run this:

        SCHTASKS.EXE /RUN /TN "AdminScript"
        

        This is my test script:

        @echo off
        net session > NUL 2>&1
        IF ERRORLEVEL 1 GOTO not_elevated
        echo This script ran WITH elevated privilages.
        goto end
        :not_elevated
        echo This script ran WITHOUT elevated privilages.
        :end
        start notepad
        

        These are the contents of d:\tools\script.log:

        This script ran WITH elevated privilages.
        

        I see that notepad ran "As administrator" because it has Elevated = Yes in Task Manager. I had to add the Elevated column to see that.
        dd214b55-7a69-405c-b117-213a1bcf01a0-image.png

        Russell VanderMey

        XanderX 1 Reply Last reply Reply Quote 1
        • RussR Russ referenced this topic on
        • RussR Russ referenced this topic on
        • XanderX Offline
          Xander @Russ
          last edited by Xander

          @Russ I'm trying to get this to work on an old (out of date) Win10 micro-PC that's x86.

          {"trigger":"Users","command":"schtasks.exe /run /tn users","ground":"background","voice":"users"},

          Here's the command in the JSON file. If I run the schtasks from a command prompt, it works. If I try to trigger this, it doesn't. Am I missing some syntax?

          (The goal is to run a batch file at c:\ which deletes a file in Program Files and replaces it with a backup.)

          EDIT: Just needed to change it to Foreground 🤦🏻‍♂️

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post