Do you have a .NET application you want to run on Vista with UAC enabled?
Of course you could make your user use the "Run As Administrator" right-mouse click, but many poor users will probably forget to do this (including me!).
So how can you make the usual popup window appear for your application? Use a manifest file!
For example, look at this simple application:
namespace
RunAsAdmin {
class Program {
static void Main( string[] args ) {
PerformanceCounter perfCounter =
new PerformanceCounter ( "Processor", "% Processor Time", "_Total" );
Console.WriteLine ( "CPU is at {0}", perfCounter.NextValue().ToString() );
}
}
}
Running this application will result in a runtime error because you need admin priviliges to access the performance counter.
Now add a manifest file to the directory of your application (<yourapp>.exe.manifest):
version="1.0" encoding="utf-8" ?>
<
assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<
assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="RunAsAdmin" type="win32" />
<
description>RunAsAdmin< FONT>description>
<
trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<
security>
<
requestedPrivileges>
<
requestedExecutionLevel level="requireAdministrator" />
< STRONG <>
requestedPrivileges>
< STRONG <>
security>
< STRONG <>
trustInfo>
< STRONG>
>
And now it will run! And has the shield added to the icon :)