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

Questions

General Discussion
3
3
716
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.
  • T
    Tony Jiménez
    last edited by Jul 4, 2021, 10:24 AM

    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.

    R 1 Reply Last reply Jul 4, 2021, 6:39 PM Reply Quote 0
    • R
      Russ @Tony Jiménez
      last edited by Russ Jul 4, 2021, 6:41 PM Jul 4, 2021, 6:39 PM

      @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

      X 1 Reply Last reply Feb 24, 2024, 4:46 PM Reply Quote 1
      • R Russ referenced this topic on Oct 15, 2022, 3:29 PM
      • R Russ referenced this topic on Oct 15, 2022, 3:32 PM
      • X
        Xander @Russ
        last edited by Xander Feb 24, 2024, 4:47 PM Feb 24, 2024, 4:46 PM

        @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
        2 out of 3
        • First post
          2/3
          Last post