How to run cmd with Admin privileges using command line

93,110

Solution 1

runas /profile /user:administrator “Driver:\folder\program”

For example, the administrator account is “AAA” and you want to run BBB.exe of C:\programs, you should follow these steps:

  1. Press Win key & R
  2. Input “CMD” in open box and click “OK”
  3. Input: runas /profile /user:AAA “C:\programs\BBB.exe” and press “Enter”
  4. Input the password of administrator AAA
  5. Press “Enter”

Hope it works.

Solution 2

You can use runas.exe /savecred /user:administrator cmdor refer this link

Share:
93,110
Ezra09
Author by

Ezra09

Updated on September 18, 2022

Comments

  • Ezra09
    Ezra09 over 1 year

    Is there a way to run/start cmd as administrator through the command line or a batch file programming in Windows 8?

    I want to create a batch file which has administrative privileges without any prompt to the user.

  • Vomit IT - Chunky Mess Style
    Vomit IT - Chunky Mess Style almost 7 years
    You should put some additional content in this answer explaining what it is doing rather than just proving some back code mixed with VBS and no explanation leaving people that don't know this code scratching their head wondering what it does. I'd look it up and test with it regardless if it was me using it and not understanding it but you get the point.
  • G-Man Says 'Reinstate Monica'
    G-Man Says 'Reinstate Monica' over 3 years
    If you promote your own software on this site, you must disclose that it is yours.
  • Andry
    Andry over 3 years
    @G-ManSays'ReinstateMonica' I don't promote or advertise anything. And this is open source, why I have to disclose an open source that it is mine?
  • G-Man Says 'Reinstate Monica'
    G-Man Says 'Reinstate Monica' over 3 years
  • Andry
    Andry over 3 years
    @G-ManSays'ReinstateMonica' A Windows shortcut is a binary file. I can't post here a binary file snippet. How you suppose to do that?