Use sudo in windows

5 Windows Alternatives to the Linux sudo Command

In other words, pseudo sudo commands

If you’ve ever used Linux or know someone who uses Linux, then you’ve probably heard of the sudo command. The command is a critical component to just about every Linux distribution and what it does is let you run a command as a different user, most notably the root user. On certain Linux distributions, you can log in as the root user by using the su command, but this is considered highly risky and no one ever does it.

Actually, it’s so dangerous that it’s disabled by default on Linux distributions like Ubuntu. Instead, you have to use the sudo command if you want to run a command as the root user. So what about Windows? Well, unfortunately, most people are logged into Windows as Administrators, which is the same as root user in Linux. However, Microsoft has tried to lessen the dangerous effects of being logged in as an Administrator by enabling User Account Control or UAC.

That way, even if the user has Administrative privileges, applications running under that account will not inherit those privileges unless it’s manually authorized by the user. This helps prevent malware and spyware from infecting a Windows user who is logged in as an Administrator.

So while Linux users have the sudo command, what do Windows user have? Are there alternatives that Windows users can use to run commands with elevated privileges? Is there a sudo command for Windows? In this article, I’ll talk about five alternatives to the sudo command for Windows users.

Note: Some of these tools are quite old now, so they may or may not work with the latest versions of Windows.

Windows Runas Command

Windows has the runas command, which is the direct counterpart to sudo on Linux. Using the runas command, you can execute a script, program or command as a different user or as an administrator. The full syntax for the runas command is:

If you wanted to open an administrative command prompt, you could type the following:

/noprofile will not load the current user profile. You can remove that if you need access to the user environment variables. If you wanted to open a text file using Notepad with administrator privileges, you could use this command:

You can checkout the Technet page on runas for more information on how to use it.

Note that when using runas command, if you install a program or make changes to settings, etc., the changes will be made to the user account that you are running the command on. For example, let’s say you have user X who is a normal user and user Y, who is an administrator. If you log into X and then do a runas using the Administrator credentials, changes will be made to the Administrator’s settings, not user X.

So if you install an application by right-clicking on the EXE file and choosing Run as Administrator, it’ll get installed to the built-in Administrator user profile, not the one you are logged into. If you want true elevated privileges like sudo without the profile issues, check out the next alternative below.

Читайте также:  Windows image tool from gigabyte

Sudo for Windows – Sourceforge

Sudo for Windows is a free program you can install that will give you the same experience of the sudo command on Linux for Windows. The only difference is that Sudo for Windows “preserves the user’s profile and ownership of created objects” as stated by the developer. This is really handy if you like to use elevated permissions for installing apps or making changes to user locations like My Documents, etc.

It’ll give you Administrative privileges, but will keep all the changes in the current profile instead of the account you’re using to run the command with. The program requires .NET version 2.0, which you can’t download individually. In order to get 2.0, you have to install .NET Framework 3.5, which include 2.0.

Once you install Sudo for Windows, you need to add the user accounts that you to allow to have elevated privileges to a specific group created by the program called Sudoers. Right-click on My Computer or This PC and click on Manage. Then expand Users and Groups and click on Groups. You should see one called Sudoers.

Double-click on Sudoers and click on the Add button.

On the next dialog, click the Advanced button and then click Find Now. This will list out all users and groups on the system. Double-click the user you want to add.

Repeat this step for however many users you want to add. Then click OK and you should see the members listed in the Members listbox shown above. Click OK and now you should be able to use the sudo GUI and command. If you right-click on a program, you’ll see the Sudo option.

You can also open a command prompt and type sudo to run command with elevated permissions.

Overall, it’s pretty nifty and works very well. However, note that this particular program is really useful for launching programs or processes either via right-click or via the command prompt, but it’s not meant for running command line apps. For example, if you wanted to do sudo mkdir “c:\Program Files\new”, this won’t work using Sudo for Windows. For that functionality, there is another program called the same thing, but by a different developer. Read below.

Sudo for Windows – Luke Sampson

There’s another developer who wrote another Sudo for Windows that lets you execute command line apps too. So let’s go back to the example about creating a new folder in C:\Program Files. You can’t really do this by default.

Above I’m using PowerShell, but you’ll get the same error using the command prompt also. However, once you install Sudo for Windows, just add the word sudo to the front of the command and it works perfectly with no errors!

To install it, you need to open PowerShell and then type in the following commands in order:

If everything works OK, you should see the following output in PowerShell after each command:

That’s it! Now you can start typing in commands and adding sudo in front. The only annoying thing about this program is that the UAC window still pops up and you have click Yes for it to work. Even with that slight annoyance, the benefits are well worth it.

Читайте также:  Штрих м linux driver

Elevate

Elevate is a program that works with UAC and doesn’t work exactly like sudo. With Elevate, it will change the executing user to Administrator like the runas command does. However, it’s useful for working in the command line or with batch files.

The main purpose of elevate is not to get around UAC, but to start a process in an elevated state from a non-elevated shell and then continuing on as normal even after the command has completed. Elevate is useful for scripting because you don’t have to worry about trying to script the whole right-clicking and running a command prompt as Administrator process.

Elevation PowerToys for Windows

For those of you who do a lot of work on the command line or work with scripts and batch files, then the Elevation PowerToys for Windows page has quite a few useful tools and scripts.

The script elevation power toys were created to overcome the frustrating aspects of UAC when trying to elevate a program from the command line or running scripts as administrators.

Hopefully, that’s enough tools and programs for you to make you feel like you’re actually using sudo on Windows. There’s no perfect replacement for it, but there are quite a few options that come close. If you use something else to elevate programs, commands or scripts in Windows, let us know in the comments. Enjoy!

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications. Read Aseem’s Full Bio

Как запустить команду ‘sudo’ в windows

Как бы я выполнил следующую команду в windows:

9 ответов:

нет sudo команда в Windows. Ближайший эквивалент — » Запуск от имени администратора.»

Вы можете сделать это с помощью runas команда с уровнем доверия администратора, или щелкнув правой кнопкой мыши программу в пользовательском интерфейсе и выбрав «Запуск от имени администратора.»

обычно вы этого не сделаете, так как вы не будете запускать его под *nix независимо. Выполните разработку в пользовательском каталоге, а затем разверните его в системных каталогах.

в Windows можно использовать команду runas. Для пользователей linux, есть некоторые альтернативы для sudo в windows, вы можете проверить это

runas команда требует, чтобы пользователи вводили пароль. Если вы не хотите вводить пароль и хотите просто щелкнуть диалоговое окно UAC, используйте Start-Process -Verb runas в PowerShell вместо .

следующий сценарий vbs делает трюк для меня. Я надел его C:\Windows\System32

пример использования в командной строке sudo net start service

Я думаю, что я попробовал шаги ниже после проведения некоторых исследований и преуспел

1.Установите scoop с помощью powershell 3 (iex (new-object net. webclient). downloadstring ( ‘ https://get.scoop.sh’)) 2. сделать совок установки —мировой судо 3. убедитесь, что пути (C:\Users\\scoop\shims & C:\ProgramData\scoop\shims) добавлена в переменную окружающего пути.

нет команды sudo в случае windows, а также нет необходимости ставить любые $. Для установки углового CLI через узел.JS командная строка в windows, я только что написал npm install-g @angular / cli и затем нажмите Enter. Это сработало отлично.

Use sudo in windows

windows-sudo lets you run an arbitrary program with elevated privilege on Windows. Remember, this is different from running the program as the Administrator user.

  1. Download the latest release from https://github.com/ysmu/windows-sudo/releases/latest
  2. Unzip it and run install.bat
Читайте также:  Windows 10 pro 2004 игровой

All functions of windows-sudo should be compatible with all 32bit and 64bit builds of Windows newer than Windows XP SP 2 (included). That being said, I will only be maintaining windows-sudo for Windows 10. windows-sudo has been tested on the following platform:

  • Windows 10 x64 Build 1607
  • Windows 10 x64 Build 1703

Copyright (c) 2016 ysmu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

windows-sudo lets you run an arbitrary program with administrative privileges on Windows.

Есть в Windows команда аналогичная команде “sudo” в GNU/Linux?

Как запускать скрипты от root`a в windows?

3 ответа 3

runas /user:mymachine\administrator cmd.exe — запустить интерпретатор команд cmd.exe от имени пользователя «administrator» компьютера «mymachine». При выполнении команды, будет запрошен пароль пользователя, от имени которого должна выполняться задача.

runas /noprofile /env /user:mydomain\admin » mmc %windir%\system32\diskmgmt.msc » — запустить консоль mmc с оснасткой «Управление дисками» от имени пользователя «admin» в домене «mydomain». Профиль пользователя не загружается, и используются текущие переменные среды. Загрузка профиля пользователя необходима только тогда, когда будет выполняться задача, которой требуются какие-либо данные из него. Если задан параметр /env то переменные окружения наследуются из среды текущего пользователя.

runas /savecred /user:admin@mydomain regedit.exe — запустить редактор реестра «regedit.exe» от имени пользователя «admin» домена «mydomain» с запоминанием введенного пароля. При наличии параметра /savecred , введенный пароль запоминается в реестре в зашифрованном виде и в дальнейшем запрашиваться не будет .

runas /showtrustlevel — отобразить уровни доверия, существующие в системе. В ответ будет отображаться перечень в виде:

В системе доступны следующие уровни доверия:
0x20000 (Обычный пользователь)

Кроме значения trustlevel равного 0x20000 можно пользоваться значениями 0x10000 , соответствующему минимальному набору привилегий и 0x40000 , стандартному для данного пользователя набору. Для просмотра отличий разных уровней доверия можно воспользоваться командой Whoami , выполняя ее в сеансе командного процессора, запускаемого с каждым из уровней trustlevel

runas /trustlevel:0x20000 cmd.exe — запустить командный процессор cmd.exe с использованием уровня доверия, полученного в предыдущем примере.

runas /trustlevel:0x40000 cmd.exe — запустить командный процессор cmd.exe с использованием стандартного уровня доверия.

Примечание: в сеансе командной строки, запущенной с использованием параметра /trustlevel , список привилегий соответствующий каждому уровню доверия можно получить с использованием команды whoami /priv , а полные сведения об учетной записи — whoami /ALL

Примечание: параметр /profile несовместим с параметром `/netonly.

Примечание: параметр /savecred несовместим с параметром /smartcard .

Оцените статью