Execute a program under a different user account.

RUNAS [/profile] [/env] [/netonly] /user:user Program

/profile Option to load the user&qt;&qt;s profile (registry)
/env Use current environment instead of user&qt;&qt;s.
/netonly Use if the credentials specified are for RAS only.
/user Username in form USER@DOMAIN or DOMAINUSER
(USER@DOMAIN is not compatible with /netonly)
Program The command to execute

runas /profile /user:mymachineadministrator CMD
runas /profile /env /user:SCOT_DOMAINadministrator NOTEPAD
runas /env /user:jDoe@swest.ss64.com "NOTEPAD "my file.txt&qt;
Enter the password when prompted.

RunAs from the Windows explorer GUI
Select an executable file, Shift-Right-click and select Run As..
This option can be hidden by setting

The error level returned by RunAs is not consistent between operating systems

In Windows 2000:
– success: &qt;ERRORLEVEL&qt;=1
– fails: &qt;ERRORLEVEL&qt;=0

In Windows XP:
– success: &qt;ERRORLEVEL&qt;=0
– fails: &qt;ERRORLEVEL&qt;=1

For Example

VER | find "2000" > nul
IF &qt;errorlevel&qt; EQU 0 GOTO s_2000

::Running XP
RUNAS /user:jDoe@swest.ss64.com "mycommand.exe"
IF &qt;ERRORLEVEL&qt;==0 Echo command succeeded
goto :eof

::Running Windows 2000
RUNAS /user:jDoe@swest.ss64.com "mycommand.exe"
IF &qt;ERRORLEVEL&qt;==1 Echo command succeeded
goto :eofRunAs Reqires the "Secondary Logon" service to be running.