[Bat] How to run as an administrator of another user

Windows

Hello!This time, let's combine batch and powershell to create a batch file that can be processed by users other than yourself with administrator privileges!

You often want to execute commands or batch files as another user, such as in a domain environment.However, if you execute it using the Runas command etc., it may be executed with general privileges and the desired operation may not be obtained.

This time, "Run with another user and administrator privileges" is useful in such cases.
I will show you how.

Use a combination of Runas command and PowerShell

Previously, I introduced the method using the Runas command and PowerShell as a method to execute as an administrator.

The Runas command is a command to execute by specifying a user in the first place. By specifying the target user name in the / user option, you can execute the process as an arbitrary user.

If you have specified a user, you will be prompted for that user's password.
After entering the password, PowerShell will run it as an administrator without a password.

The following is a summary of it.

Runas / user: [username] "powershell start-process [process] -verb runas"

In this site, when you copy "" ", it may be full-width.In that case, please replace it with a half-width "" "after pasting.

This is an image of another user executing the "Execute with administrator privileges" command.
I think you should use Whoami / priv etc. for confirmation.

It's a little confusing in this way, but I was able to achieve the desired behavior.

I hope it helps you.

Comment

Translate »
I copied the title and URL