0

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
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
blaq
  • 59
  • 1
  • 8

2 Answers2

1

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.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
  • runas.exe cannot elevate if UAC is enabled, which will often be the case nowadays, especially as XP goes the way of the dodo. – Eryk Sun Apr 25 '15 at 22:07
0

You can always walk around that one:

Create a shortcut to your script. Go to Properties - Shortcut - Advanced- Check Run as Administrator

Every time you open the shortcut you will have your .exe opened with admin privileges.