Thursday, March 26, 2009

UAC refereneces (C#, .NET)

UAC (User Account Control)


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 systemVersion number
Windows 76.1
Windows Server 2008 R26.1
Windows Server 20086.0
Windows Vista6.0
Windows Server 2003 R25.2
Windows Server 20035.2
Windows XP5.1
Windows 20005.0

Summary

Other References





No comments:

Post a Comment