Solved

set "run as administrator" from batch file

Posted on 2008-10-21
12
11,243 Views
Last Modified: 2012-08-13
Is it possible to set the "Run as administrator" compatibility option from a batch file? If so, what is the syntax to set it for a file called abc.exe?
0
Comment
Question by:Scott Helmers
12 Comments
 
LVL 6

Expert Comment

by:dacselat
ID: 22767095
runas /user:administrator abc.exe
0
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 22767125
I don't have Vista, so I have no way to test this.
C:\Windows\System32\runas.exe/user:CONTOSO\Administrator abc.exe

Also, for Shell:
http://technet.microsoft.com/en-us/sysinternals/cc300361.aspx
0
 
LVL 30

Author Comment

by:Scott Helmers
ID: 22767287
dacselat: Thanks for the syntax -- however, it looks like that will run abc.exe as an administrator each time I execute the command.

What I want to do is actually set the compatibility option so that whenever the user executes abc.exe -- by whatever means they choose -- the program will run as administrator.  in other words, I want to change the attributes of abc.exe not merely run it once as admin.
0
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 22767451
scott, Try the following:
1. Right-click the application, and then click Properties.
2. Click the Compatibility tab.
3. Select the Run this program as an administrator checkbox, and then click OK.

Reference:
http://www.vistaclues.com/always-run-an-application-as-an-administrator/
http://www.howtogeek.com/howto/windows-vista/always-start-an-application-in-administrator-mode-on-windows-vista/
0
 
LVL 30

Author Comment

by:Scott Helmers
ID: 22767772
Darren: thanks, but I know how to do this from the UI. My question is how I can do it from a batch file...
0
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 22767903
So you want a batch file to setup a program to run as admin?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 30

Author Comment

by:Scott Helmers
ID: 22768032
yes
0
 
LVL 3

Accepted Solution

by:
DarrenMcCall earned 500 total points
ID: 22776039
I've searched and can't find how Vista stores this information.  It might be in the registry, but I'm not sure.  If I could find this information out, I might could provide a solution.
0
 
LVL 30

Author Comment

by:Scott Helmers
ID: 22776264
Thanks, Darren.

I've doubled the point value for the question in hopes that someone can find where the settings are stored.
0
 
LVL 30

Author Closing Comment

by:Scott Helmers
ID: 31508265
Thanks for trying, Darren. Unfortunately, no one was able to provide a solution.
0
 
LVL 1

Expert Comment

by:CycoTron
ID: 24874680
I have found the solution.

You can use "Application Compatibility Toolkit" to create an SDB file specifying the "RunAsAdmin" Compatibility mode. The file can then be imported via command line and the settings will apply to the local machine.

the command to import an SDB file to a machine is:  "sdbinst file.sdb"
0
 
LVL 30

Author Comment

by:Scott Helmers
ID: 24879021
Thanks for the tip, CycoTron -- and thanks for taking time to post this information on a closed question. I haven't solved the problem yet but will definitely look into this.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi All Just a quick one for everybody. I was recently looking into setting the default User Account Picture for all my vista clients within the network but on closer inspection the group policy setting only allows you to set the default pictur…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now