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.
Thanks!
-
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!
Thanks
-
@bzowk ,
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 spoolerI just tested it on my Win10 box and it worked. I have UAC turned on though, so maybe that's the difference.
EDIT 7/4/21:
Check out this solution too: https://www.triggercmd.com/forum/topic/1453/questions/2
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