Open Notepad using Administrator from Command Line with Runas Command
I have installed Windows XP on a Virtual Machine and was working on with a regular user account. I was trying to edit Oracle’s TNSNAMES.ORA using Windows XP’s built-in text editor Notepad, but could not due to lack of privilege. Using an Administrator Account to edit the restricted file could be done in two ways. It could either be with the GUI (Graphic User Interface) or the CLI (Command Line Interface).
With GUI it would be plain easy by using Windows File Explorer then navigate to the system folder “WINDOWS”. Look for the file “notepad.exe”, right click and choose “Run as” on the pop up menu. Select “The following user:” radio button on the Run as pop up window. Enter the username “Administrator” and the corresponding password. Then you’re ready to edit the restricted file such as TNSNAMES.ORA.
With CLI it would be much easier by using the simple command “runas”. The following line of command below will be very useful especially on scripts.
runas /user:mycomputernamemydesiredusername notepad
Just provide the equivalent “mycomputername” and “mydesiredusername”. In my case the computer name is “techxplore” and the username is administrator. Thus, it would show like the following:
C:runas /user:techxploreadministrator notepad
This will then ask for a password. Fill-in the password and there you can open the Notepad with administrator privilege. Runas command could be used to open other applications with different user from the current login easily from the command line interface of Windows XP.
Posted on
Friday, August 28th, 2009 at 9:27 am under 