How to run an app in admin mode in Vista and 7
-
I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.
-
I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.
It's not the application that detects if you're running as admin or not, it's the OS. Any user of Vista/Windows 7 (including Administrator) by default do not run with admin privilege - it must be requested. Certain actions require admin rights - like writing to HKEY_LOCAL_MACHINE in the registry or creating files within the Program Files directory (and sub-directories)., You can make your app show that UAC dialog and request admin rights by using the following manifest file.
<?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="YourApp" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>Save this file in the folder containing your app with the same name as your app and the extension of .manifest. For instance, if your app is called MyTestApp.exe, save this file as MyTestApp.exe.manifest. Now when you run the app it will pop up the UAC dialog. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.
This article tell you how it is done - Adding UAC elevation manifest in Visual C++ 8.0/ Visual Studio 2005 C or C++ project[^]
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
I have seen some applications warn that you have to run it in admin mode, if you do not run it in admin mode in both Windows Vista and 7. How do they detect if it is running with admin privileges or not. Some application even invoke the UAC (user access control) dialog to pop up, as soon as they run. Please someone enlighten me about this.
U need to embed a manifest in your application which will allow your application to be recognized by vista to run as administrator : This link will give us step by step solution for the same . http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/6d870287-e364-4151-851d-70605c0e6a6d/[^] Hope it helps and solves ur purpose. Regards, Kushagra
-
U need to embed a manifest in your application which will allow your application to be recognized by vista to run as administrator : This link will give us step by step solution for the same . http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/6d870287-e364-4151-851d-70605c0e6a6d/[^] Hope it helps and solves ur purpose. Regards, Kushagra