Run as other user windows

How to Run a Program as a Different User (RunAs) in Windows 10?

In all supported Windows versions it is possible to run applications on behalf of another user (Run As) in the current session. This allows you to run a script (.bat, .cmd, .vbs, .ps1), an executable (.exe) or an application installation (.msi, .cab) with another user (usually elevated) privileges.

For example, you can use the RunAs to install apps or run MMC snap-ins under the administrator account in an unprivileged user session. The opportunity to run a program as a different user may be useful when an application is configured under another user (and stores its settings in another user’s profile, which the current user cannot access), but it must be started with the same settings in another user’s session.

In Windows 10 there are several ways to run a program/process on behalf of another user.

How to Run an App as Different User from File Explorer?

The easiest way to run an application on behalf of another user is to use the Windows File Explorer GUI. Just find an application (or a shortcut) you want to start, press the Shift key and right-click on it. Select Run as different user in the context menu.

[alert]Note. If the menu item “Run as different user” is missing, see the next section.

In the next window, specify the name and password of the user under whose account you want to run the application and click OK.

Open the Task Manager and make sure that the application is running under the specified user account.

“Run As Different User” Option is Missing in Windows 10

If there is no Run as different user option in the File Explorer context menu, open the Local Group Policy Editor ( gpedit.msc ) and make sure that the Require trusted path for credential entry policy is disabled (or not configured) in Computer Configuration -> Administrative Templates -> Windows Components -> Credential User Interface.

Using the RunAs Command to Run a Program as Another User from CMD

You can use the Windows built-in cli tool runas.exe to run apps applications as a different user from the command prompt. The runas command also lets you to save the user’s password to the Windows Credential Manager so that you don’t have to enter it every time.

Open the command prompt (or the Run window by pressing Win+R). To start the Notepad.exe under the administrator account, run this command:

runas /user:admin «C:\Windows\notepad.exe»

runas /user:»antony jr» notepad.exe

In the next window, the prompt “Enter the password for admin” appears, where you have to enter the user’s password and press Enter.

Your application should open. In my case, this is cmd.exe. The window title says “running as PCName\username“:

For example, you can open the Control Panel under a different user:

runas /user:admin control

If you need to run a program under a domain user, use the following name format: UserName@DomainName or DomainName\UserName . For example, to open a text file using notepad on behalf of a domain user, use the command:

runas /user:corp\server_admin «C:\Windows\system32\notepad.exe C:\ps\region.txt»

Sometimes you need to run a program as a domain user from a computer that is not joined to the AD domain. In this case, you need to use the following command (It is assumed that the DNS server specified in your computer’s network settings can resolve this domain name):

runas /netonly /user:contoso\bmorgan cmd.exe

If you don’t want to load user profile when starting the program as different user, use the /noprofile parameter. This allows the application to launch much faster, but may cause incorrect operation of programs that store app data in the user’s profile.

How to Use RunAs Without Password Prompt?

You can save the user credentials (with password) that you enter. The /savecred parameter is used for this.

runas /user:admin /savecred “C:\Windows\cmd.exe”

After specifying the password, it will be saved to the Windows Credential Manager.

The next time you run the runas command under the same user with the /savecred key, Windows will automatically use the saved password from the Credential Manager without prompting to enter it again.

To display a list of saved credentials in Credential Manager, use the following command:

rundll32.exe keymgr.dll, KRShowKeyMgr

However, using the /savecred parameter is not safe. Because a user, in which profile it is saved, can use it to run any command with these privileges and even change another user password. Also, it is easy to steal passwords saved in the Credential Manager so it is recommended to prevent a Windows from saving passwords (and never save the password of the privileged administrator accounts).

How to Create a Shortcut to Run As Different User?

You can create a shortcut on your desktop that allows you to run the program as a different user. Just create a new shortcut, and specify the runas command with the necessary parameters in the Location field

When you run such a shortcut, you will be prompted to enter a user password.

If you additionally specify the /savecred parameter in the runas shortcut, then the password will be prompted only once. The password will be saved in Credential Manager and automatically used when you running the shortcut without prompting for a password.

Such shortcuts are quite often used to run programs that require elevated permissions to run. However, there are safer ways to run a program without administrator privileges, or disable the UAC prompt for a specific application.

How to Run MMC Snap-Ins As a Different User?

In some cases, you have to run one of Windows management snap-ins as a different user. For example, you can use the following command to run the Active Directory Users and Computers (ADUC) RSAT snap-in as a different user:

runas.exe /user:DOMAIN\USER «cmd /c start \»\» mmc %SystemRoot%\system32\dsa.msc»

In the same way you can run any other snap-in (if you know its name).

Add “Run As” Option to Start Menu in Windows 10

By default in Windows 10 Start Menu items do not have the “Run As” option. To add the context menu “Run as different user”, enable the “Show Run as different user command on Start” policy in User Configuration -> Administrative Templates ->Start Menu and Taskbar section of the Local Group Policy Editor (gpedit.msc).

Читайте также:  Роли пользователей windows server

Or, if the gpedit.msc is missing, create a new DWORD parameter with the name ShowRunasDifferentuserinStart and value 1 in the registry key HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer. You can use the following PowerShell command to add the reg parameter:

New-ItemProperty -Path «HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\Explorer» -Name ShowRunasDifferentuserinStart -Value 1 -PropertyType DWORD -Force

Update the Group Policy settings ( gpupdate /force ) and make sure that a new context menu More -> Run as different user has appeared for the programs in the Start menu.

Ошибка при использовании команды runas, параметра Run as Administrator или run в качестве другого пользовательского параметра после обновления Windows Server: доступ отказано.

В этой статье приводится ряд обходных способов решения проблемы, в которой после обновления Windows Server нельзя использовать команду, параметр Run as Administrator или Run в качестве другого пользовательского runas варианта.

Оригинальная версия продукта: Windows Server 2012 R2
Исходный номер КБ: 977513

Симптомы

Рассмотрим следующий сценарий.

  • Вы обновляете компьютер, на который работает Windows Server.
  • Вход в качестве стандартного пользователя.
  • Вы пытаетесь использовать одну из следующих функций:
    • runas команда
    • Запуск в качестве параметра Администратор
    • Запуск в качестве другого пользовательского параметра

В этом сценарии вы получите следующее сообщение об ошибке:

Причина

Список управления дискреционным доступом (DACL) для службы Secondary Logon неправильно задаваем при обновлении Windows Server. Эта проблема не позволяет обычному пользователю запускать эту службу и запускать приложение в качестве другого пользователя.

Обход 1. Использование Sc.exe командной подсказок

Вы можете использовать командную Sc.exe для настройки безопасности по умолчанию после обновления сервера.

Прежде чем запускать эти команды, необходимо войти в систему в качестве администратора.

Для этого выполните указанные ниже действия.

Откройте окно командной строки.

В командной строке введите следующую команду, а затем нажмите клавишу ВВОД:

В командной строке введите следующую команду, а затем нажмите клавишу ВВОД:

Эта команда завернута для читаемости.

Закройте окно командной строки.

Попробуйте использовать одну из следующих функций:

  • runas команда
  • Запуск в качестве параметра Администратор
  • Запуск в качестве другого пользовательского параметра

Кроме того, убедитесь, что вы можете переключить пользователей и что служба Secondary Logon запускается правильно.

Обходное решение 2. Использование групповой политики

Консоль управления групповой политикой можно настроить политику на основе домена, которая задает безопасность конфигурации по умолчанию после обновления сервера. Для этого обхода необходимо создать новый объект групповой политики (GPO). И его следует связывать так, чтобы новый GPO применялся только к затронутым компьютерам.

Для этого выполните указанные ниже действия.

Изменение групповой политики в консоли управления групповой политикой.

Найдите политику: Конфигурация компьютера\Политики\Параметры Windows\Параметры безопасности\Системные службы.

Откройте службу Secondary Logon.

Выберите поле Определение этого параметра политики, а затем выберите Включено.

Установите режим запуска службы в ручном режиме.

Расширйте узел безопасности, чтобы убедиться, что задаются следующие свойства и объекты.

Свойство Объекты
Пользователи, прошедшие проверку Шаблон запроса, состояние запроса, иждивенцы, начните, приостановите и продолжите, допрашивайте, считывайте разрешения, User-Defined управление
Builtin\Administrators Полный доступ
Интерактивны Шаблон запроса, состояние запроса, иждивенцы, начните, приостановите и продолжите, допрашивайте, считывайте разрешения, User-Defined управление
Служба Шаблон запроса, состояние запроса, иждивенцы, пауза и продолжение, опрос, User-Defined управление
Системные Шаблон запроса, состояние запроса, иждивенцы, запуск, пауза и продолжение, допрос, остановка

Выберите ОК, чтобы применить изменения безопасности.

Выберите ОК для применения изменений групповой политики.

Применить GPO к затронутым компьютерам, ожидая обновления групповой политики или запуска обновления вручную.

Попробуйте использовать одну из следующих функций:

  • runas команда
  • Запуск в качестве параметра Администратор
  • Запуск в качестве другого пользовательского параметра

Кроме того, убедитесь, что вы можете переключить пользователей и что служба Secondary Logon запускается правильно.

Мы не рекомендуем это обходное решение, так как разрешения повторно в процессе обновления групповой политики. Однако исправить неправильную безопасность необходимо только один раз после обновления.

Дополнительные сведения

Дополнительные сведения о команде runas можно получить на следующем веб-сайте Microsoft TechNet:

Дополнительные сведения об использовании консоли управления групповой политикой можно найти на следующем веб-сайте Microsoft TechNet:

Windows runas command syntax and examples

Runas is a very useful command on Windows OS. This command enables one to run a command in the context of another user account. One example scenario where this could be useful is: Suppose you have both a normal user account and an administrator account on a computer and currently you are logged in as normal user account. Now you want to install some software on the computer, but as you do not have admin privileges you can’t install the same from the current account. One option is to switch user and login as administrator. Instead, you can do the same by simply using runas command. You just need to launch the installer from command prompt using runas command and by providing administrator login id and password.

Let’s see the syntax of runas command with some examples.

Run a program from another user account

The command to launch a program using another user credentials is given below.

For example, if you want to open registry editor as administrator of the computer, the command would be as below.

After running the above command, you will be asked to enter the password of administrator account. After password validation, registry editor will be opened with the administrator account credentials.

To specify arguments to the program:

If you need to provide arguments to the program that need to be invoked as another user, you can put the program name and the parameters in double quotes.

For example to open the file C:\boot.ini as administrator, the command would be:

Running command prompt as another user :

If you have multiple commands need to be executed with administrator(or any other user )credentials, instead of running each command using runas, you can open command prompt window once as the administrator and then run all the commands in that window. Below is the command for opening a command window using runas.

It will launch new command window after printing the above message.

Run a batch file as administrator

To run a batch file as administrator of the computer, you need to mention the path of the batch file in the place of command in the runas syntax.

For example, to run the batch file located at c:\data\mybatchfile.bat, you need to run the below command.

Some questions regarding runas command:

When I use runas command, I am getting the error ‘This program is blocked by group policy. For more information, contact your system administrator’. How can I fix this?

Administrator of your system might have disabled users to login from command prompt. In group policy editor, this setting can be found in the below node.

Computer Configuration -> Windows settings -> Security settings ->Local Policies -> User rights assignment

In the above path, look for the setting ‘Deny logon as a batch job‘. If you have administrator privileges, you can disable this settings. Otherwise, you need to contact the system/domain administrator.

Unable to runas administrator.
I have only one user ‘rakesh’ and that user is the Administrator. When I execute this command –

C:\Users\rakesh>runas /user:administrator cmd

Enter the password for administrator:
Attempting to start cmd as user «RAKESH-LAP\administrator» …
RUNAS ERROR: Unable to run – cmd
1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.

I enter the password for user ‘rakesh’. What am I missing here?

Hey!!
I’m encountering the same problem. Did u get the solution.
Please help me.

If rakesh is the administrator, then the command would be runas /user:rakesh cmd

Administrator is the name of a specific, built-in account – not a pseudonym for any administrator account, or the Rakesh account. The error you are receiving is due to the Administrator account having a different password to the Rakesh account, so inputting the Rakesh password does not authenticate correctly.

runas /user:computername\rakesh cmd

Substitute “computername” with your computer name. To find your computer name, press either of the following:

So if you want the run the ‘Superadmin’ account for your domain that is called ‘Beefpower’ you would enter.

runas /user:beefpower\superadmin cmd

That would tell the computer to request a signin for the account named superadmin on the beefpower domain.

To log into with a local account you can substitute the name of the computer with a period.

So if the computer name was noodlepower you could use
runas /user:.\administrator cmd

.\administrator would substitute the period for the name of the computer you are currently logged into.

By default the computer will use a local account, but this has it’s uses. Mostly when you are trying to log on as a local account when a domain account is listed at the login screen or you don’t know or want to type the terrible default names Microsoft assigns computers.

runas is useful if the current logged in account does not have admin access. In your case you already have admin privileges. why are you doing runas admin then?

Check if the administrator account is disabled, or the password has expired. ‘Net user administrator’ will show this info.

im having the same problem as Rakesh. regardless of whether or not im on admin already i would like a solution. i don’t care if i don’t need to do this to install something, this doesn’t work on limited users either.

before you ask yes Secondary Logon says: Status=started; Startup Type=Automatic; Log On As=Local System.

yes i have tried changing the password from a blank, it doesn’t accept it otherwise

what i want is to open another cmd shell as the built in administrator.
the error i get is:
RUNAS ERROR: Unable to run – cmd
1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.

no administrator does not have logon hour restrictions

no policy restriction (to the best of my knowledge) is enabled, i’ve formatted this myself.

this problem i running me through the walls i would really apreciate any help that could gget this fixed thank you.

I’ve the exact same problem as tecthusiast described

No solution what so ever either

oh and no im not connected to a domain

I’m trying to add a new user using runas, it does not work.

A new command window flashes and it does not print any error in the main window. But I don’t see the user added.

Try chnage
net user /add newuser password
to
net user newuser password /add
It should work

I have RUNAS in my batch script and I’ve got a problem.
First call of RUNAS works fine, but second call (after some other commands) doesn’t work. It starts program with current user, not with user I specified in RUNAS command.
Why so?

When attempting this command, I receive the message “Enter the password for the administrator:”, which obviously I do not have, or I wouldn’t be going to this amount of trouble.
Additionally, my command does not go straight to “C:\runas…”
Rather, it automatically goes C:\Users\(my username)>runas, which seems like it may be the problem that sparks the program to ask for the administrator password.
(Yes, my computer has parental controls on it which I am attempting to bypass. It is important to note that no, parents do not always have your “best interests” in mind, and as this laptop is my primary means through which I complete schoolwork I need to be able to install programs and update them at will, without needing to beg for a password. It is not nearly as simple as “just ask your parents” or “be responsible and show them you can handle it” for some people, and I do not have the time to argue with a parent whenever I need to install a program such as Evernote or change some small setting such as which programs are displayed in the taskbar.)

I think your not understanding the command at all. The runas command is setup to allow you to run applications or the command prompt with an admin password for that machine without having to switch who is logged in. If I (your dad has admin rights to the laptop) then If I ran the runas command I could use my credentials to install or run something with admin right on your profile. So you have to have the administrator password or a users password that has admin rights to run this. You would need a different program for what you are trying to do. You would need a way to get the admin password or a way to login with admin rights.

think like a hacker and with a hidden video cam watching you get your dad to enter the password for whatever reason you can get that he will do and capture that password. to hack is not always via computer code….

It looks like your parents have created a user account for you which has less privileges (standard user). You might want to look at it another way. Lets say, you can change the Administrator password to nothing (blank) and move your user account under Administrators group (but make sure the Operating System is not Home Basic or any such lower tier OS ).
You might want to use the “net user” command.
First of all, do the following to change the admin password. in command prompt, type “net user Administrator *” and press enter-type a new password as required and confirm by re-typing it . Then type “runas /user:Administrator cmd”. this will open command prompt in admin mode
1. in command prompt type, “net users” and press enter . identify your username and take not of the administrator user account
2. type “net localgroup users” or try “net localgoup Administrators” and press enter to see which local group your user account is in. make sure you remember your username
3. type “net localgroup Administrators /add” and press enter
4. type “net localgroup Administrators” to confirm that your username is now under administrators group. You should now have full admin privileges to do the unthinkable.

You might also, as a way of courtesy , not tell your parents what happened to the admin password.

the runas asked the user to insert the password, what if i want to ask to insert the user name and the passweord

I used to be able to run the following two commands from the Run window (WinKey+R) in WinXP, but on Win7 the second command (delete arpcache) requires elevation (Run as administrator), even when launched from the Run window under an admin user acct:

cmd /k ipconfig /flushdns
cmd /k netsh interface ip delete arpcache

I understand the basics of UAC, and from what I gather from numerous forum threads and several experiments of my own, there is simply no way to run the second command directly from the Run window (short of creating a batch file to run a “scheduled task” and running the batch file from the Run window).

I thought maybe there would be a way to do this using Runas, but have not succeeded yet. At best, it appears I can only open an elevated Command Window using Runas, then still have to enter the “netsh interface ip delete arpcache” command in that elevated window. (…in which case, WinKey > type “cmd” > Ctrl+Shift+Enter is faster to open an elevated command window than using Runas from the Run window)

Am I overlooking something? Is there any way to do this with a single Runas command from the Run window (WinKey+R) without using a batch file?

(The advantage would be that the command would be stored in RunMRU, readily available for re-use in the Run window, and I can propagate it along with other favorite RunMRU commands to other computers via REG file.)

I need to put the password in the same command line. How can I do that?

Thanks for your input, however my problem is that after running “runas/user:administrator regedit” (or regedit.exe) my console asks for administrator’s password BUT WILL NOT ACCEPT input, the cursor just sits there and WILL NOT accept keystroke entries! Please help.

How can I use this in batch files without creating a new window?

Sort of like this, but this doesn’t work:

i have 3 user on my pc and for the one i need to log into i can not cause i forgot the password
right now i m using guest and i am trying to reset password for the one i need to be log into iv search on youtube of how i can get into my main user ?
administrator peter norton jr guest
my main user is the peter norton jr but i forgot the password ?
i tried the cmd prompt but cannot reset/change password doing something wrong?
thank you

i also dont know the password for administrator or for peter norton jr
tried sereval command prompts on how to change or reset password

hey, i tried for run this command which i have been create new user account before it’s called “backdoor” and password “backdoor”

and i have a problem with error 740: The requested operation requires elevation.

anyone can help me?

How would I use runas in which the command and the arguments both have spaces, e.g., something like:

If the argument(s) don’t have spaces and don’t need quotes, then there is no issue and it runs, e.g.,

Or if the command does not have spaces, but the argument(s) do, then there is also no issue, e.g.,

However, when both the command and the argument(s) have spaces and need to be quoted, then it will not run.

Note that I was able to get this to work using cmd as a wrapper so that the actual command to runas does not have spaces, but the syntax was even more ugly and contorted than above, e.g.,

Any suggestions to get this to work with the extra cmd wrapper?

Correction to my question:
Any suggestions to get this to work WITHOUT the extra cmd wrapper?

Hi I am trying to launch my application using runas command using the following syntax
runas /user:xxxx “c:\application.exe D:\” the first path is the application which i need to launch and the second command argument is the input to the launched application. But right now , it is showing error msg in ProcessShellCommand(cmdInfo) . Please suggest some alternatives

Hi, I have a service that run some scripts with administrator privileges, but the scripts work only if it was run by a simple user.
I have change the account connection of the service, but the scripts keep been launch with administrator privileges.
So how can I run it?

Is there a way to have the command line script launch as admin and enter the password without typing it in manually?

Have you found a resolution as yet?
I am also looking for a solution to enter a password automatically.

Hey I made the runas batch file but when the cmd-like window opens up I am unable to type in any text for the administrator password. Any thoughts?

it just isn’t showing any placeholder characters for what you’re typing in… so it only seems like it’s not working 😉

I have batch file which make changes to the local machine host file. This batch needs to be run with a local administrative user. I have the user name and password both. How can I put this in a batch file so that batch file execute using the run as different user and don’t ask for the password from user because they would not have the password.

What are the relations among RUNAS TAKEOWN ICACLS gpedit.msc ATTRIB
took me a long time to delete a folder playing with all this new and old commands

I would like to install a bat file in user’s PC in server environment. bat file is saved in desktop of the user account. I want to install it with the user login
Please advise about the cmd comments

I have tried the below, but not sure if my actual script is working though to launch wordpad as admin and capture the password directly.

start RUNAS /User:domain\username PASSWORD:abcd123 wordpad.exe

Any suggestions if someone else got this working?

Is there a way to have the command line script launch as different user and enter the password without typing it in manually? using runas or any other command?

Читайте также:  Синхронизация смартфона с windows 10
Оцените статью