How to set the UAC elevation with C# (.NET)?
1. Create a manifest file looks like below.
2. Adding the manifest to the executable.
tab BuildEvent, in the post-build,
"$(DevEnvDir)..\..\SDK\v2.0\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)";#1
You can change the paths to make a build possible.
Local User, Application Directory
The directory of a local user and an application directory is different from Windows Vista and Windows XP.
Windows Vista/Windows Server 2008: %LocalAppData%\Microsoft\Team Foundation
Windows Server 2003 / Windows XP: %UserProfile%\Local Settings\Application
So, we can use environment values to get them.
Environment.GetEnvironmentVariable("LOCALAPPDATA"); // Get an application data path
Environment.GetEnvironmentVariable("USERPROFILE"); // Get an user directory
OS Version number
Operating system | Version number |
---|---|
Windows 7 | 6.1 |
Windows Server 2008 R2 | 6.1 |
Windows Server 2008 | 6.0 |
Windows Vista | 6.0 |
Windows Server 2003 R2 | 5.2 |
Windows Server 2003 | 5.2 |
Windows XP | 5.1 |
Windows 2000 | 5.0 |
Summary
Other References
UAC in C++, Managed. http://support.microsoft.com/kb/310294
No comments:
Post a Comment