Admin Tip #12: Run programs as another user under Windows 2000 or Windows XP |
Hits: Failed to execute CGI : Win32 Error Code = 3
|
runas /user:waynesdomain\myadminaccount regedt32.exe
Runas can be used to start any program, MMC console, or Control Panel item as long as the following requirements are met:
Using Runas across the network may fail. The credentials used to run the program may not have adequate access to the network share. If you try to start a program, MMC console, or Control Panel item from a network location using Run as, it might fail because the credentials used to connect to the network share are different from the credentials used to start the program.
Windows Explorer and desktop icons can be started using Runas functionality. You do not have to log off as a user and back on as an admin. Very helpful troubleshooting a problem on a user's workstation or for performing admin tasks from your workstation. Hold down the shift key and right-click the shortcut or icon you want to run. You will be prompted for login information and then the program will run with that account's authenication, righat and permissions. Remember to unload the program if you are doing this on a user's workstation.
To get all the commandline options:
runas /?
A better use of runas is remote administration. Telnet into the Windows 2000 / Windows XP workstation/server and run programs as administrator. We have sms remote for this purpose but if you don't have a product like SMS inplace, this would work well to support Windows 2000 / Windows XP workstations.
Runas is not scriptable because pw has to be entered interactively. There is a utility to allow runas to be scripted. Taken from the utility site:
Sanur is a tiny Win32 console utility that 'pipes' a password into the Windows 2000/XP/2003 Runas utility, thereby making Runas scriptable. Usage Pipe your normal Runas commandline into Sanur and specify the password on Sanur's commandline or use the /i switch to have Sanur read the password from a file:- RUNAS | SANUR password RUNAS | SANUR /i [drive:][path]filename Examples Pipe the password 'pa55w0rd' into Runas:- runas /u:domain\username program.exe | sanur pa55w0rd Pipe the password from the file named password.txt into Runas:- runas /u:domain\username program.exe | sanur /i password.txt Same as above but any Runas errors, such as a logon failure, will be displayed:- runas /u:domain\username program.exe >&2 | sanur /i password.txt
Related Tips:
Step-by-Step Guide to Using Secondary Logon in Windows 2000
After you install Windows 2000 Service Pack 1, the runas command may not work correctly
Runas Utility Uses Default Profile