How to Use the runas command and how to automatically enter the password of RUNAS

Source: Internet
Author: User

In win2k, choose Start> program> attachment, find the calculator, press shift, right-click, and select "running mode... ". At this time, a dialog box will pop up asking you which user identity you want to use to run the program.
I don't know if you have used the win2k function. If you use the win2k English version, you cannot select the "running mode" after holding down shift... "But" runas... ", that is, the command to be mentioned today.
Enter runas in cmd to get help. Today, we only use it in the simplest way, that is, how to use this command to run a program as another user.

In fact, the command is very simple:
Runas/user: user_name program.exe
User_nameis the name of the user who needs to run the program, and program.exeis the program name. If program.exe is not in the system32 directory, You need to specify the specific path.
To prove this process, an experiment is to run the at command using the guest account to view the list of current scheduled tasks. As we all know, guest does not have this permission by default, therefore, as long as this command actually works, the words "Access Denied" will appear. Here, we use this command:
Runas/user: guest "cmd.exe cmd/k at.exe"
Cmd.exe calls the cmd program, while cmd/k refers to the cmd command followed by the/k parameter, in order to retain the screen of the current execution result.

(Note: This is due to the excessive number of commands, and there is a space in the middle. It is used as an example. If there is only one command, such as at.exe, then no quotation marks are required)

Example:
(1) runas/user: administrator "C: Program FilesAutoCAD R14acad.exe"
(2) enter the password: (the password will not be visible at the time of input)
(3) In this way, you can use the "administrator" user permission to start the program. Generally, you can use it to execute the installation program, so that you do not need to switch the user to install"

Since the running program is opened in a new window, but not in the original window, if I do not use the parameter .exe cmd/k, the window will flash and fail to see the effect.

After running this command, you will ask for the guest password, fill it in, press enter, wait for a moment, a cmd window will appear, which says "Access Denied", and, in the cmd window, there is also the words "(run as guest)" along.
This tool can also be used in the domain, and you can add a personal configuration file, it is really nice ~~~
-------
RUNAS usage:

RUNAS [/profile] [/env] [/netonly]/user: <UserName> program

/Profile if you need to load the user's configuration file
/Env must use the current environment instead of the user environment.
/Netonly is used only when the specified credential is limited to remote access.
/User <UserName> should be in the form of USER @ DOMAIN or DOMAINUSER
Command Line of program EXE. See the following example.

For example:
> Runas/profile/user: mymachineadministrator cmd
> Runas/profile/env/user: mydomainadmin "mmc % windir % system32dsa. msc"
> Runas/env/user: user@domain.microsoft.com "notepad" my file.txt ""

Note: The user's password is entered only when prompted.
Note: USER @ DOMAIN is not compatible with/netonly.
However, since RUNAS has to enter its own password every time, it is very troublesome. We can also use other methods:
How to automatically enter the RUNAS Password
When a non-administrator user logs on, if you want to run the program with the Administrator permission, you need to use the runas command. when running the script, you cannot simply use the pipeline to enter the password, there are the following methods to avoid the trouble of entering a password each time.
1. Use the runas/savecred option that comes with the system. After you enter the password for the first time, the creden。 are saved.
Features: commands that can be run cannot be restricted, resulting in poor security.

2. Using sanur, sanur is a small program that can pass the password or content in the file to the runas program using the pipeline method.
Runas | sanur password
Runas | sanur/I [drive:] [path] filename
Features: the password is stored in plaintext.
----------------------------------
About Sanur
Sanur is a tiny Win32 console utility that pipes a password into the Windows 2000/XP/2003 Runas utility, thereby making Runas scriptable.
Licencing
Sanur is freeware. There is no longer for personal or using ate use. For more details see the readme.txt file has ded in sanur.zip.
Usage
Pipe your normal Runas commandline into Sanur and specify the password on Sanurs commandline or use the/I switch to have Sanur read the password from a file :-
RUNAS <options> | SANUR password
RUNAS <options> | SANUR/I [drive:] [path] filename
In otherwords, just add | SANUR password to the end of your working Runas command.
Examples
Pipe the password pa55w0rd into Runas :-
Runas/u: domainusername program.exe | sanur pa55w0rd
Pipe the password from the file named password.txt into Runas :-
Runas/u: domainusername program.exe | sanur/I password.txt
Same as abve but any Runas errors, such as a logon failure, will be displayed :-
Runas/u: domainusername program.exe> & 2 | sanur/I password.txt
Support
As of Sanur is no longer supported. if you are having problems getting Sanur to work please read the troubleshooting AND the FAQ pages, or seek an alternative solution. please dont send me any emails relating to Sanur.
For example, runas/u: domainguest notepad.exe | sanur/I 123.jpg folder. In this way, you cannot directly view the file and hide it.

----------------------------------
Related Pages:
Http://www.commandline.co.uk/sanur_unsupported/index.html

3. When lsrunas is used, the function is similar to sanur, but it does not need to run runas and comes with complete parameters for execution.
Features: the password is stored in plaintext.
Related Pages:
Aspx? Item = lsrunas "> http://www.moernaut.com/default.aspx? Item = lsrunas

4. Use the enhanced version of lsrunase and lsrunas, and use the encrypted password. The built-in software LSencrypt is used to generate encrypted strings.
Usage:
Lsrunase/user: administrator/password: 41 BngA ==/ domain:/command: notepad.exe/runpath: c:
All parameters must be complete, including:
The user is the running account.
Password is the encrypted string
Domain is the machine name or domain name, or you can leave it blank to represent the Local Machine
Command is the name of the program to be run. If the parameter is included, quotation marks must be placed at the beginning and end of the command.
Runpath is the program startup path.
Features: It can perfectly replace runas and avoid directly saving the password in the script.
Related Pages:
Http://www.moernaut.com/default.aspx? Item = lsrunase

5. Using cpau, cpau is also a program that replaces runas. It is powerful and can use an encrypted password.
Usage:
Cpau-u administrator-p password-ex notepad-file start_notepad.txt-enc
Cpau-file start_notepad.txt-dec
The preceding command can encrypt and save the command to be executed as a file and load the file during execution.
Features: it can protect scripts and commands executed by others from being viewed by others, but there are some problems when using the network path.
Related Pages:
Http://www.joeware.net/win/free/tools/cpau.htm

6. Using autoit, autoit is a tool for automated script execution. It can complete many automated tasks and compile the script into an exe file to run it directly, this allows you to hide password information.
Features: powerful functions, but complex operations.
Related Pages:
Http://www.autoitscript.com/autoit3/

Other tools can perform similar operations.
Reference page:
Http://www.commandline.co.uk/sanur/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.