How to Run Commands as Administrator
Hey Guys -
Just found this utility today and playing with it with my existing automation setup. Quick question, though. The first thing I tried to do is to have the ability to start / stop Windows (10) services using "net start service). When testing, it failed to start the service yet know the command is correct. Pretty sure it's because the execution requires elevation. What can I do (if anything) to achieve this?
I've already installed the background service and when looking in the forum for an answer, saw the example of using "sc start service" therefore tried it instead, but it didn't work either. The system is Windows 10 x64 with UAC disabled and I obviously have full admin rights.
OK, I tried a few things and found the below workaround using a utility I use with CPAU. It works, but if there's a better way; please let me know.
Basically, I copied Elevate.exe (had already downloaded) to Windows\System32 only because it was already in my path. Instead of executing "sc start service", I used "elevate sc start service". I tested it in a non-elevated command prompt first which worked so tried as a trigger and it worked!
That should have worked. Background commands are elevated commands by default because they run in the context of the Windows service that runs as Local System.
I have a background command called "Restart Print Spooler" that runs:
sc stop spooler & sc start spooler
I just tested it on my Win10 box and it worked. I have UAC turned on though, so maybe that's the difference.
Check out this solution too: https://www.triggercmd.com/forum/topic/1453/questions/2