set "run as administrator" from batch file

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?
LVL 31
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAsked:
Who is Participating?
 
DarrenMcCallConnect With a Mentor Commented:
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
 
dacselatCommented:
runas /user:administrator abc.exe
0
 
DarrenMcCallCommented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
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
 
DarrenMcCallCommented:
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
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
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
 
DarrenMcCallCommented:
So you want a batch file to setup a program to run as admin?
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
yes
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
Thanks, Darren.

I've doubled the point value for the question in hopes that someone can find where the settings are stored.
0
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
Thanks for trying, Darren. Unfortunately, no one was able to provide a solution.
0
 
CycoTronCommented:
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
 
Scott HelmersVisio Consultant, Trainer, Author, and DeveloperAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.