CMD Simulator
User Managementrunas

RUNAS Command – Run Programs as Different User in Windows

Learn how to use the RUNAS command to execute programs under a different user account in Windows CMD. Guide covers syntax, /user, elevation, and security best practices.

Rojan Acharya·
Share

The RUNAS command is a Windows Command Prompt utility that allows you to run specific programs and commands with different credentials than your current logon. Use RUNAS /user:UserName program to execute programs as Administrator, a domain user, or another account—essential for privilege escalation, testing under different contexts, and performing administrative tasks without logging off.

Whether you're a system administrator running occasional elevated commands without switching users, a developer testing applications under different user contexts, or an IT professional performing one-off administrative tasks, RUNAS provides flexible credential switching from the command line. Security-conscious organizations use RUNAS to minimize time spent in elevated contexts while maintaining the ability to perform necessary administrative operations.

This comprehensive guide covers RUNAS syntax, the required /user parameter, practical examples for common scenarios, security considerations, troubleshooting tips, and frequently asked questions. By the end, you'll confidently use RUNAS for privilege elevation and multi-account operations in Windows environments.

What Is the RUNAS Command?

The RUNAS command starts a process under a different user account than the one currently logged in. You specify the target user with /user:UserName and the program to run. Windows prompts for the password (unless /savecred was used previously), then launches the program in the new user's security context. RUNAS is available in Windows 2000 and later, including all Windows 10, Windows 11, and Windows Server editions.

RUNAS supports local accounts (COMPUTER\user), domain accounts (DOMAIN\user), and UPN format (user@domain.com). The launched program runs in a separate process with the specified user's token, allowing you to test applications, run administrative tools, or access resources as a different user without logging off your current session.

RUNAS vs Right-Click "Run as Administrator"

  • RUNAS: Command-line; scriptable; specify exact user; supports /savecred
  • Right-click Run as admin: GUI; always uses Administrator; not scriptable
  • RUNAS enables automation and running as any user, not just Administrator.

Syntax

RUNAS [/noprofile | /profile] [/env] [/netonly] [/savecred] [/smartcard]
      [/user:<UserName>] program

Parameters

ParameterDescription
/user:<UserName>Required. Specifies the user account (DOMAIN\user or user@domain)
/noprofileLoads user profile with minimal environment
/profileLoads user profile (default)
/envUses current environment instead of user's
/netonlyCredentials for network access only; uses local credentials for local resources
/savecredUses previously saved credentials (first run prompts for password)
programProgram or command to run

How to Use RUNAS Command

Run Command Prompt as Administrator

Execute CMD as the local Administrator account:

RUNAS /user:Administrator cmd.exe

You'll be prompted for the Administrator password. A new Command Prompt window opens with Administrator privileges.

Run Program as Domain User

Execute a program as a domain account:

RUNAS /user:DOMAIN\adminuser notepad.exe

Use for accessing domain resources or testing under domain user context.

Run with Saved Credentials

First run prompts for password; subsequent runs use saved credentials:

RUNAS /savecred /user:Administrator cmd.exe

Use with caution—saved credentials can be a security risk. Only use on trusted, secured systems.

Run with Current Environment

Use /env to inherit current environment variables:

RUNAS /env /user:Administrator "cmd /k cd C:\Projects"

Common Use Cases

  1. Run administrative tools – Use RUNAS to launch Registry Editor, Services, or Event Viewer as Administrator without switching users.

  2. Test application under different user – Developers use RUNAS to test how applications behave under standard vs. admin accounts.

  3. Access domain resources – Run a program as domain user when logged in locally to access domain shares and resources.

  4. Minimize elevated exposure – Use RUNAS for specific elevated tasks instead of logging in as Administrator.

  5. Scripted elevation – Incorporate RUNAS in scripts for automated tasks requiring different credentials.

  6. Troubleshooting permission issues – Run the failing program as Administrator to isolate permission vs. application logic issues.

  7. Multi-account testing – QA teams use RUNAS to test under various user accounts without multiple logons.

  8. Service account simulation – Run programs as service account to test service behavior without deploying the service.

  9. Compliance and auditing – RUNAS creates clear audit trail of which user performed actions.

  10. Help desk operations – Support staff use RUNAS to perform user-specific troubleshooting without knowing user passwords.

Tips and Best Practices

  1. Never use /savecred on shared systems – Saved credentials can be exploited. Use only on secure, single-user workstations.

  2. Use /netonly for remote access – When you need domain credentials only for network resources, /netonly keeps local operations under your account.

  3. Quote paths with spaces – Use RUNAS /user:Admin "C:\Program Files\App\app.exe" for paths containing spaces.

  4. Verify with WHOAMI – After RUNAS, run WHOAMI in the new window to confirm you're under the expected account.

  5. Use least privilege – Run as the minimum privilege level needed; don't default to Administrator for all tasks.

  6. Document RUNAS usage – In scripts, document why RUNAS is used and which account is required.

  7. Consider UAC – On modern Windows, "Run as Administrator" from right-click may be simpler for one-off elevation.

  8. Test in non-production first – Verify RUNAS commands work correctly before using in production scripts.

Troubleshooting Common Issues

RUNAS Prompts for Password Repeatedly

Problem: RUNAS asks for password every time even with /savecred.

Cause: Credential Manager may not store RUNAS credentials; Group Policy may block saved credentials.

Solution: Check Group Policy: Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options. "Network access: Do not allow storage of passwords and credentials for network authentication" blocks /savecred. Use /savecred only when policy allows.

Prevention: Understand organizational credential storage policies. Use alternatives like scheduled tasks with "Run as" for automated elevation.

"Access Denied" When Using RUNAS

Problem: RUNAS fails with access denied.

Cause: Wrong password, account disabled, or account has "User cannot change password" / "Password never expires" restrictions. Some accounts (like default Administrator) may be disabled.

Solution: Verify account is enabled. Check password is correct. For domain accounts, ensure domain connectivity. Try logging in interactively with the account to verify it works.

Prevention: Test RUNAS with the account in a non-critical scenario first. Document account requirements.

RUNAS Opens Window Then Closes Immediately

Problem: RUNAS launches a window that closes right away.

Cause: The program may have exited immediately (e.g., cmd.exe with no /k to keep open). Or the program encountered an error on startup.

Solution: Use RUNAS /user:Admin cmd.exe and add /k to keep prompt open: RUNAS /user:Admin "cmd /k". For other programs, run from an existing elevated prompt to see error messages.

Prevention: Use cmd /k when testing with Command Prompt. Redirect output to file for debugging: RUNAS /user:Admin "cmd /c program > log.txt 2>&1".

Program Fails Under RUNAS But Works When Logged In

Problem: Application runs when logged in as user but fails under RUNAS as same user.

Cause: RUNAS may use /noprofile by default in some configurations, loading minimal environment. Application may depend on profile paths, environment variables, or registry HKEY_CURRENT_USER settings.

Solution: Use /profile explicitly: RUNAS /profile /user:user program. Or use /env to inherit current environment. Ensure application dependencies are available in RUNAS context.

Prevention: Document application requirements. Test RUNAS during application deployment validation.

Related Commands

WHOAMI – Verify User Context

After RUNAS, use WHOAMI in the new window to confirm you're running under the expected account.

When to use: Verification after elevation. See WHOAMI command guide.

NET USER – User Account Management

NET USER manages user accounts. RUNAS uses existing accounts; NET USER creates and configures them.

When to use: Account management vs. running as existing account.

TASKLIST – Process Ownership

TASKLIST shows which user owns each process. Useful to verify RUNAS-launched processes.

When to use: Verify process user context.

Frequently Asked Questions

What does the RUNAS command do?

RUNAS runs a program under a different user account than the one currently logged in. You specify the user with /user:UserName and the program to run. Windows prompts for the user's password, then launches the program with that user's credentials.

How do I run Command Prompt as Administrator using RUNAS?

Use RUNAS /user:Administrator cmd.exe. Enter the Administrator password when prompted. A new Command Prompt window opens with Administrator privileges. Use RUNAS /user:Administrator "cmd /k" to keep the window open.

Can RUNAS use a domain account?

Yes. Use RUNAS /user:DOMAIN\username program for domain accounts. Or use UPN format: RUNAS /user:user@domain.com program. Ensure the computer is domain-joined and can reach the domain controller.

What is RUNAS /savecred?

/savecred saves the password in Windows Credential Manager after the first successful entry. Subsequent RUNAS commands with the same user don't prompt for password. Use with caution—saved credentials can be a security risk on shared or compromised systems.

Why does RUNAS prompt for password every time?

/savecred may be disabled by Group Policy. Or you may not have used /savecred on the first run. Check "Network access: Do not allow storage of passwords and credentials for network authentication" in Group Policy.

Can I use RUNAS in a batch file?

Yes, but the password prompt is interactive—batch files will wait for user input. For non-interactive scripts, use scheduled tasks with "Run whether user is logged on or not" and "Run as" account, or use PowerShell's Start-Process with -Credential.

What is RUNAS /netonly?

/netonly uses the specified credentials only for network access. Local resource access uses your current (local) credentials. Use when you need domain credentials to access network shares but want local operations under your account.

How do I run a program with spaces in the path?

Quote the entire program path: RUNAS /user:Admin "C:\Program Files\My App\app.exe". Include any arguments inside the quotes if needed.

Does RUNAS work with PowerShell?

Yes. Use RUNAS /user:Administrator powershell.exe to launch PowerShell as Administrator. For running commands as different user from within PowerShell, use Start-Process with -Credential parameter.

Can RUNAS run batch files?

Yes. Use RUNAS /user:Admin "cmd /c C:\scripts\mybatch.bat" or RUNAS /user:Admin "C:\scripts\mybatch.bat". The batch file executes in the specified user's context.

Quick Reference Card

CommandPurposeExample Use Case
RUNAS /user:Admin cmdRun CMD as AdminQuick elevation
RUNAS /user:Admin "cmd /k"Run CMD as Admin, keep openInteractive admin work
RUNAS /user:DOMAIN\user programRun as domain userDomain resource access
RUNAS /savecred /user:Admin cmdSave credentialsRepeated elevation (use cautiously)
RUNAS /netonly /user:DOMAIN\user cmdNetwork-only credentialsRemote access, local context
RUNAS /env /user:Admin programUse current environmentPreserve env vars

Try RUNAS Command Now

Practice elevation and user context switching in our Windows Command Simulator. Explore WHOAMI to verify user context, SCHTASKS for scheduled task automation, and the full Commands Reference for more Windows CMD utilities.

Summary

The RUNAS command enables running programs under different user accounts from the command line, supporting privilege escalation, domain user context, and multi-account testing. The required /user: parameter specifies the target account; Windows prompts for password unless /savecred was used. Use RUNAS for administrative tasks without logging off, testing under different contexts, and scripted elevation. Combine with WHOAMI to verify the new user context. Follow security best practices: avoid /savecred on shared systems, use least privilege, and document RUNAS usage in scripts. Master RUNAS for flexible credential management in Windows administration.