Search code examples
windowsbatch-fileuser-accountselevated-privileges

How to run batch file as an elevated user?


I have a batch file that creates another user using this code:

net user /add TheAccount passWORD
net localgroup administrators TheAccount /add

And I did this so that my program would later run commands elevated without the UAC popping up, because it could use its own account...

But I hit a roadblock when I noticed that RunAs doesn't allow elevation.

I really need to be able to run a program elevated without any third-party tools that I would have to include.

Thanks in advance.


Solution

  • Thanks for all the help, but I found an answer with Microsoft Psexec.exe with the -h option or the
    -s option.