Does Windows have a command similar to the "sudo" command in GNU / Linux?


How to run scripts as root in windows?


runas /user:username "command.exe /parameters"

runas /user:mymachine\administrator cmd.exe – run the cmd.exe command interpreter as the "administrator" user on the "mymachine" computer. When executing the command, you will be prompted for the password of the user on whose behalf the task is to be executed.

runas /noprofile /env /user:mydomain\admin " mmc %windir%\system32\diskmgmt.msc " – start the mmc console with the Disk Management snap-in as user "admin" in the "mydomain" domain. The user profile is not loaded and the current environment variables are used. Loading a user profile is only necessary when a task will be executed that requires any data from it. If the /env parameter is given, then environment variables are inherited from the environment of the current user.

runas /savecred /user:admin@mydomain regedit.exe – run the "regedit.exe" registry editor as the "admin" user for the "mydomain" domain, remembering the entered password. If the /savecred parameter is /savecred , the entered password is stored in the registry in encrypted form and will not be /savecred in the future.

runas /showtrustlevel – display the trust levels that exist on the system. In response, a list will be displayed in the form:

The following levels of trust are available in the system:
0x20000 (Normal user)

In addition to the trustlevel value equal to 0x20000 you can use the values 0x10000 , which corresponds to the minimum set of privileges and 0x40000 , the standard set for a given user. You can use the Whoami command to view the differences between different trust levels by running it in a shell session that starts with each trustlevel level trustlevel

runas /trustlevel:0x20000 cmd.exe – Start the cmd.exe shell using the trust level obtained in the previous example.

runas /trustlevel:0x40000 cmd.exe – Run the cmd.exe shell using the default trust level.

Note: in a command line session launched using the /trustlevel parameter, the list of privileges corresponding to each trust level can be obtained using the whoami /priv , and the full account information can be obtained from whoami /ALL

Note: The /profile option is incompatible with the `/ netonly option.

Note: The /savecred incompatible with the /smartcard option.

Here is the option with passing the password:

echo пароль | runas /netonly /user:workgroup\user "command.exe"
Scroll to Top