Blog Examples

Examples for run as administrator from user

Different possibilities to run application with administrator privileges from standard user by RunAsRob and RunAsSpc


Packages of Ninite Installer can install by a limited user without to know the administrator credentials

1) with RunAsRob the part RunAsAdmin
RunAsRob Ninite

2) or RunAsSpc with administrator login information of administrator in plain text
RunAsRob Ninite

3) or RunAsSpc with encrypted file and hidden paassword.
RunAsSpc Ninite


Run Powershell script as administrator

First of all, enable powershell script on machine.

Now there are various ways.

1) Run script as administrator from admin account with elevated privileges.

  1. Self elevate powershell script is working, by call the same script with elevated privileges inside the script. I am against doing this, because it is the risk to get an endless loop
  2. or elevate the powershell script by calling the script via another powershell start script, which elevate the main script.
    >> Start-Process powershell.exe -ArgumentList '-file c:\test\powershell\pscript.ps1' -Verb RunAs <<
  3. or create a shortcut to your Powershell script with command PowerShell.exe -Command "& 'C:\Temp\script.ps1'"
    and set in the shortut property tab -> Advanced -> Run as administrator
    Run Powershell script as administrator

2) Run script as administrator from standard user account.

  1. Create a shortcut to your Powershell script with command PowerShell.exe -Command "& 'C:\Temp\script.ps1'"
    and set in the shortut property tab -> Advanced -> Run as administrator
    After start of shortcut, you will be asked to enter administrator credentials.
  2. An elegant way to run Powershell script as administrator from standard user and avoid entering the credentials and bypass the UAC is using RunAsAdmin from RunAsRob. You just have to authorize the script in RunAsAdmin and launch it via RunAsRob.
    See following example configuration with a Powershell script >> c:\scrpt.ps1 <<
    1. Authorize the complete call in RunAsAdmin >> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe c:\scrpt.ps1 <<
    2. with login option >> as system <<
    3. Now you can call scrpt.ps1 via RunAsRob and it is running with system rights under standard user account.
      >> "C:\Program Files\RunasRob\RunAsRob.exe" "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe c:\scrpt.ps1" <<
    Run Powershell script as administrator from user

Run cmd as administrator to get the command line with elevated privileges

Run command line with elevated privileges from administrator account.

Run command line with elevated privileges from user account.


Run batch file as administrator

Launch a batch file with elevated privileges from an administrator account.

Create a shortcut of the batch file, select in properties of the shortcut -> advanced -> run as administrator.

Start a batch file as administrator from a user account.

Choose the easiest way and use RunAsRob https://runasrob.com

  1. Allow the directory of the batch file in RunAsAdmin, a part of RunAsRob
  2. Start your batch file with command >> "C:\Program Files\RunasRob\RunAsRob.exe" "C:\test\batch01.cmd" <<
  3. Call this command directly, in a batch file, any script or in a shortcut
Run batch file as administrator from user

Links


Date: 2024-04-12
Data protection
Imprint