Runas

Command on Windows to run a program as another user

runasDeveloper(s)| Microsoft

|

Initial release| February 17, 2000; 25 years ago (2000-02-17)
Operating system| Microsoft Windows
Type| Command
License| Proprietary commercial software
Website| docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc771525(v=ws.11)

In computing, `runas` (a compound word, from “run as”) is a command in the Microsoft Windows line of operating systems that allows a user to run specific tools and programs under a different username to the one that was used to logon to a computer interactively.[1] It is similar to the Unix commands `sudo` and `su`, but the Unix commands generally require prior configuration by the system administrator to work for a particular user and/or command.

## Microsoft Windows

[edit]

The `runas` command was introduced with the Windows 2000 operating system.[2] Any application can use this API to create a process with alternate credentials, for example, Windows Explorer in Windows 7 allows an application to be started under a different account if the shift key is held while right clicking its icon. The program has the ability to cache verified credentials so that the user only ever has to enter them once.

### Syntax

[edit]

The command-syntax is:[3]

runas [{/profile | /noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel:<TrustLevel>] [/savecred] /user:<UserAccountName> program

#### Parameters

[edit]

This section is paraphrased from the `runas /?` command.

* `/noprofile`: Speeds up the loading of the application by skipping the loading of the user's profile. Note that this might not speed up every application.
* `/profile`: Do not skip loading the user's profile. This is the default setting.
* `/env`: Use the actual environment, not the user's.
* `/netonly`: Specifies that the given credentials are to be used for Remote access only.
* `/savecred`: Credentials saved by the previous user. This setting is not available on Windows 7 Home or Windows 7 Starter Edition. This setting is left out from Windows XP Home Edition as well.
* `/smartcard`: Specifies that the credentials will be supplied from a smartcard.
* `/user`: Format is either `USER@DOMAIN` or `DOMAIN\USER`.
* `/showtrustlevels`: Shows help (list of usable trust level parameters) for the /trustlevel switch.
* `/trustlevel`: One of the trust levels listed by the /showtrustlevels switch.
* `program`: Command line for the executable file. See examples below.

Note: Only type in the user's password, when the system asks for it.

Note: The `/profile` switch is not compatible with the `/netonly` switch.

Note: The `/savecred` and the `/smartcard` switches may not be used together.

### Examples

[edit]

runas /noprofile /user:machine\administrator cmd
runas /profile /env /user:domain\admin "mmc %windir%\system32\dsa.msc"
runas /user:user@domain.example.org "notepad C:\filename.txt"
runas /user:administrator /savecred "shutdown /i"

## Inferno

[edit]

The command is also included in the Inferno operating system.[4]

### Syntax

[edit]

`runas` writes the `user` to `/dev/user` and invokes `cmd` with the given arguments.

runas user cmd [arg...]

Note: The command is only invoked if setting of the username succeeds.

## See also

[edit]

* Comparison of privilege authorization features
* sudo
* doas
* Principle of least privilege
* User Account Control, which disables the Administrator SID for the desktop, allowing it to re-enabled by exception.

## References

[edit]

1. ^ "Runas". learn.microsoft.com. 2009-09-11. Retrieved 2024-07-04.
2. ^ "MS-DOS and Windows command line runas command". computerhope.com. Retrieved 2024-07-04.
3. ^ "Runas - Run under a different user account - Windows CMD - SS64.com". ss64.com. Retrieved 2024-07-04.
4. ^ "Inferno's RUNAS(1 )".

## Further reading

[edit]

* Frisch, Æleen (2001). Windows 2000 Commands Pocket Reference. O'Reilly. ISBN 978-0-596-00148-3.
* Stanek, William R. (2008). Windows Command-Line Administrator's Pocket Consultant, 2nd Edition. Microsoft Press. ISBN 978-0735622623.

## External links

[edit]

Wikibooks has a book on the topic of: Guide to Windows Commands

* Sysinternals ShellRunas
* Alternative Runas tools
* `runas(1)` – Inferno General commands Manual

* v
* t
* e

Windows command-line programs and shell builtins

Ecosystem|

| Interpreters|

* COMMAND.COM
* Command Prompt
* PowerShell
* Recovery Console

|

Terminals|

* Windows Console
* Windows Terminal

File system navigation|

* cd (chdir)
* dir
* popd
* pushd
* tree

File management|

* attrib
* cacls
* cipher
* compact
* copy
* del (erase)
* deltree
* icacls
* mkdir (md)
* mklink
* move
* openfiles
* recover
* ren (rename)
* replace
* rmdir (rd)
* robocopy
* takeown
* xcopy

Archiving|

* expand
* extrac32
* extract
* makecab
* pax
* tar

Disk management|

* chkdsk
* convert
* defrag
* diskcomp
* diskcopy
* diskpart
* diskraid
* diskshadow
* drvspace
* fdisk
* format
* fsutil
* label
* manage-bde
* MSCDEX
* refsutil
* subst
* scandisk
* sys
* vol
* vssadmin

Processes|

* at
* exit
* kill
* runas
* sc
* schtasks
* shutdown
* start
* taskkill
* tasklist

Registry|

* assoc
* ftype
* reg
* regini
* regsvr32

User environment|

* chcp
* cmdkey
* date
* graftabl
* mode
* path
* set
* setver
* setx
* time
* title
* ver
* where
* whoami

File contents|

* comp
* edit
* edlin
* fc
* find
* findstr
* print
* type

Scripting|

* choice
* clip
* cscript
* doskey
* echo
* for
* forfiles
* goto
* if
* more
* pause
* prompt
* rem
* timeout

Networking|

* arp
* bitsadmin
* curl
* getmac
* hostname
* ipconfig
* nbtstat
* net
* netsh
* netstat
* nslookup
* PathPing
* ping
* rpcping
* route
* scp
* setspn
* sftp
* ssh
* ssh-add
* ssh-agent
* ssh-keygen
* ssh-keyscan
* tracert
* winrm
* winrs

Maintenance and care|

* auditpol
* dism
* dispdiag
* driverquery
* eventcreate
* eventtriggers
* gpresult
* gpupdate
* logman
* mofcomp
* msiexec
* ntbackup
* pentnt
* pnpunattend
* pnputil
* REAgentC
* relog
* sfc
* sxstrace
* systeminfo
* tpmtool
* tpmvscmgr
* tracerpt
* typeperf
* w32tm
* WBAdmin
* wecutil
* wevtutil
* winmgmt
* winsat
* wmic

Boot management|

* bcdedit
* bootcfg
* bootsect
* fixboot
* fixmbr

Software development|

* break
* debug
* exe2bin
* QBasic
* wsl

Miscellaneous|

* cls
* dpath
* help

* List of DOS commands
* Environment variables
* Windows Support Tools

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template