A simple option is to include a manifest that indicates that the application needs administrator rights. Then Vista will automatically offer an elevation of privilege. The manifest should look something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="ApplicationName" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
You can use the mt.exe tool to add it to an existing application.
Alternatively, you can restart the program with administrator rights immediately before the actual update. Thus, the user will not need to start with administrator rights always - only during the update.
source
share