Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/future4tech/public_html/wp-includes/functions.php on line 6114
RUNAS – Windows CMD Command - Future4Tech

RUNAS – Windows CMD Command

Execute a program under a different user account (non-elevated).

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

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

      Display the trust levels that can be used:
      RUNAS /showtrustlevels

      Run a program at a given TrustLevel:
      RUNAS /trustlevel:TrustLevel program

Key
   /noprofile       Do not load the user's profile.
                    This causes the application to load more quickly, but
                    can cause some applications to malfunction.

   /profile         Load the user's profile. (default)

   /env             Use the current environment instead of user's.

   /netonly         Use the credentials for remote access only.

   /savecred        Use credentials previously saved by the user.
                    This option is not available on Windows 7 Home or
                    Starter Editions and will be ignored.

   /smartcard       Load the credentials from a smartcard.

   /user            UserName in the form USER@DOMAIN or DOMAIN\USER

   /trustlevel Level  One of levels enumerated in /showtrustlevels.
                      RunAs is not able to launch an application with an elevated
                      access token.

   program          The program to run.

Enter the password when prompted.
/profile is not compatible with /netonly.
/savecred is not compatible with /smartcard.

When you start a program with RunAs /netonly, the program will execute on your local computer as the user you are currently logged on as, but any connections to other computers on the network will be made using the user account specified.

Without /netonly everything will run under the user account specified.

The RUNAS command unlike most other CMD and DOS commands requires that it’s command line is quoted, it uses the regular C runtime library command line parser. This also means that RUNAS requires the backslash \ as an escape character, not the standard ^ escape used by other CMD commands.

RunAs Reqires the “Secondary Logon” service to be running.

The error level %ERRORLEVEL% returned by RunAs: success = 0, failure = 1

Run with Elevated permissions

In Windows Vista and above, you can run a script with elevated permissions by right clicking and choosing “Run As Administrator”

The RunAs command predates elevation, so it has no switch for running an elevated command.
An alternative is to invoke the UAC dialogue by calling the VBScript .ShellExecute function.

If you are already running elevated, for example an elevated CMD shell, then RUNAS will launch an application as elevated, but this is equally true just running them without RUNAS, it makes no difference.

When a script is run with elevated permissions several aspects of the user environment will change: The current directory, the current TEMP folder and any mapped drives will be disconnected.

RunAs from Windows Explorer

Select an executable file, Shift-Right-click and select Run As..
This option can be hidden by setting
HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
HideRunAsVerb=1

You may also like...

1 Response

  1. froleprotrem says:

    Thanks for another magnificent post. Where else may just anyone get that type of info in such an ideal method of writing? I’ve a presentation next week, and I’m at the look for such info.

Leave a Reply

Your email address will not be published. Required fields are marked *


Notice: ob_end_flush(): Failed to send buffer of zlib output compression (0) in /home/future4tech/public_html/wp-includes/functions.php on line 5464