Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows VisualStudio , +
I need to create an application which needs to create files/folders in "C:\Program Files","Users[username]" and Sys32. Also the application needs to make some registry entry.
 
This application needs to work on Vista and higher. Also, on Windows Server 2003 and higher.
 
The above Operating Systems have the concept of User Account Control (UAC), where to access Program Files and writing in registry requires admin privileges.
 
I looked into many forums and found that using Microsoft SDK we can check whether the current user have admin privileges or not . But the function "CheckTokenMembership" fails for Vista and higher version of OS.
 
I also found a solution where manifest file can be used to tell OS in advance that the current application requires admin privileges. This is done using "requestedExecutionLevel" tag.
 
I am using Visual Studio 2005 to create the application. When we create an application in Visual Studio a default manifest file is created. Can I change this manifest file to include "requestedExecutionLevel" tag, so that my application always runs with admin privileges?
 
Is there any other method through which my application runs with admin privileges without asking user (admin or standard) to run my application as "run as admin"??
 
Thanks!
Posted 12-Apr-13 0:44am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Go to the Propertis page of your project in Visual Studio, click on Linker -> Manifest File in the tree view. Then in the right hand pane select the privilege you require in the UAC Execution Level selector. In all cases this will raise the prompt in Windows unless UAC is turned off.
  Permalink  
Comments
Member 8032827 at 12-Apr-13 6:36am
   
I am using Visual Studio 2005 and it does not have the option of "UAC Execution Level".
Can I modify the default manifest file?
Richard MacCutchan at 12-Apr-13 7:01am
   
I think so, but it's a while since I did it (or used VS 2005). You need to have an entry like: <requestedexecutionlevel level="requireAdministrator" uiaccess="false">. Are you sure there is nothing in the properties that allows you to change it?
Member 8032827 at 15-Apr-13 0:49am
   
Hi thanks for the response.
I have checked it on forums as well there is no properties option in VS 2005 for doing so.
Richard MacCutchan at 15-Apr-13 2:55am
   
Did you see this MSDN article?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 310
1 OriginalGriff 295
2 Afzaal Ahmad Zeeshan 224
3 Sergey Alexandrovich Kryukov 195
4 BillWoodruff 160
0 OriginalGriff 6,499
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,193
3 Manas Bhardwaj 4,657
4 Maciej Los 4,120


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 12 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100