Search code examples
windowsadministratoraltiris

Script to Run as Admin


I would like to create a script that will open a cmd prompt as admin and then run my exe, msi, or bat file.

my current scripted cmd is

msiexec.exe /i c:\temp\Cisco_Agent\CiscoAgentDesktop.msi /qn

Solution

  • See this TechNet article: Runas command documentation

    From a command prompt:

    C:\> runas /user:<localmachinename>\administrator cmd
    

    Or, if you're connected to a domain:

    C:\> runas /user:<DomainName>\<AdministratorAccountName> cmd
    

    Take a look here to learn how to use runas with a password automatically.