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.
@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:
This is what the Action settings look like:
On the General Tab, click this "Run with highest privileges" checkbox. That basically tells it to run "As administrator", aka elevated.
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.