Run application as administrator from user with Runas or RunAsSpc and pass the credentials including the password

>> runas /user:myadmin /savecred "c:\path\program.exe" <<
You will asked then for the password of myadmin only for the first call, but at next call it is running without asking,
because the password is saved in the credential manager of windows.
Consider the security risk of runas savecred.

>> runasspc.exe /user:myadmin /password:"password" /program:"c:\path\program.exe" <<
The password can pass directly to RunAsSpc.

>> runasspc.exe /cryptfile:"AnyApplicationWithCredentials.spc" <<
Login information are stored with the authorized application in the encrpyted file. The encrypted file is created with the graphical user interface RunAsSpcAdmin.

Download RunAsSpc >>>


Runas command, syntax, parameters and the usage in Windows program files, batch files or other scripts to start it as administrator.

First we will show you how the runas command syntax and runas command parameters look like and how to get your target step by step.
Use the command line window by typing cmd inside your Windows search bar to run your cmd system.
A command line window will open, which will give you permission to use several command line orders.
Running an application as administrator requires the following syntax:

runas /user:UserName program [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]

runas /smartcard [/user:UserName] program [ [/noprofile | /profile] [/env] [/savecred] ]

runas /trustlevel:TrustLevel program

Explanation of runas arguments:

Note: /profile is not compatible with /netonly and /savecred is not compatible with /smartcard.


cmd run as administrator - example

1.) If you are logged in with an administrator account,
you can simply right-click and select run as administrator on command line icon in the task bar of windows
or the file cmd.exe in the windows system directory to run it with administrator privileges.

Right click Run as administrator

2.) If you are logged in with a limited standard user account,
You can simply right-click and select run as administrator on command line icon in the task bar of windows
or the file cmd.exe in the windows system directory to run it with administrator privileges
after you entered the administrator credentials when prompted.

UAC Dialog enter administrator credentials

3.) To show you how to use runas in command line of windows as administrator or as limited standard user
for scripts or other automatic processes, please take a look at the following syntax of runas and its arguments:

Possible username syntax

The Runas command and its parameter you can use in a command line window, can also be used with the same syntax inside
a shortcut, a batch file or any other script.
>> runas /user:administrator "c:\windows\system32\cmd.exe" <<
>> runas /user:administrator "c:\path\myprogram.exe parameter" <<
Runas command

Then insert your administrator password with these credentials and confirm it again with "enter".
Runas password

Password to runas command directly in the call is described in the next section.


Run as administrator and the problem on scripting with runas

If a problem appears and you are asking yourself
"How do I fix run as administrator including the credentials with password for scripting and other automatic processes?"
do not despair at once. A most common problem in that case for example is that you maybe tried to use your password at first command line directly like:
>> runas /user:administrator /password:password "c:\windows\system32\cmd.exe" <<

But this is not working. You have to use the argument savecred to store this login information with password inside the credential manager of your computer for the next call by using the command:
>> runas /user:administrator /savecred "c:\windows\system32\cmd.exe" <<
Then you will be asked for the password only after the first call. The next call runas take the password from the credential manager.

But savecred is a security problem. The stored credentials allow users to run any file or program with these credentials, not just the specific one you wanted to.
Therefore you also have to authorize additionally the specific application to start your desired program with administrator rights.

An easy tool to do that, including to pass the password, is RunAsSpc by this way:
>> runasspc.exe /user:admin /password:passwd /program:c:\windows\system32\cmd.exe<<
Runasspc command

It has nearly the same syntax and parameters runas has too. In addition this tool can save your login information including the authorized program in an encrypted file.
In that manner you are avoiding that any application can run with administrator rights.
>> runasspc /cryptfile:"path\folder\yourCryptfile"<<
Runasspc command crypt file

This encrypted file can create with the graphical user interface RunAsSpcAdmin in the download package
or as well with runasspc.exe by the command:
>> runasspc /cryptfile:"path\folder\yourCryptfile.spc" /domain:localhost /user:admin /password:passwd /program:c:\windows\system32\cmd.exe <<
Each of your application can get its own crypted file with own file name.

Besides of that Runasspc is portable. So you can use a configured encrypted file on other computers directly, without installation procedure. By that way you can assign runasspc.exe with one or more encrypted files to other users by using a network share, usb memory stick or any other place from where limited users can start the specific program with administrator rights.


Runas with password - alternatives and utilities

There are a lot of runas password tools. A comparison of them with properties you will find at https://runas.eu
Almost all of them can be configured to run as administrator with saved password using it via run as different user.

Just one tool - RunAsRob - of that list goes another way and puts the user account itself temporarily into the local group of administrators and does not need a different account to run an application with administrator rights.

The advantage of this method is that the user start program as administrator with its own profile and settings. Printers, shares, NTFS rights and registry settings remain unchanged for the user.

Because of that approach RunAsRob does not need an encrypted file with stored administrator credentials. The authorized programs are written to the registry. If a user wants to run an application as administrator, then RunAsRob checks the relevant directory in your registry about permission rights. This solution makes it possible to authorize a program path with wildcards or to authorize complete folders with its contents, you want to allow to run with administrator privileges. With this method you are very flexible in your in your configuration and you can use it for any program, setup, batch file or other script.

Additionally RunAsRob offers the option "login as system", you can set for each application separate. Run under system account is a powerful option because a system account used on a local machine grants more rights than an administrator account does. You get access to backup folders, profile folders and a lot of system directories an administrator account don't have access. By running as system you can bypass the UAC dialog, because a system account knows no a blocking UAC. The option run under system account is useful for a process like monitoring, driver installation, copy job, install an update, other software installation procedures, backup and other things for which you do not need a user profile or settings of a standard account.

All of this makes RunAsRob to a little powerful tool for small and big environments. It works well and harmonic with Windows, system policies, NTFS rights, Active Directory and its organizational units. You can authorize specific computers, computer groups and users or complete user groups to run a specific application as administrator from network or local machine to delegate tasks.

RunAsRob Screenshot
RunAsRob RunAsAdmin Screenshot


Useful links about run as administrator


Date: 2024-04-12

Data protection

Imprint