2023年11月15日 星期三

Create Manifest for Vista UAC if Not Running Under Administrative Rights vista uac Windows Vista User Account Control

 http://talkdelphi.blogspot.com/2009/04/create-manifest-for-vista-uac-if-not.html

  Create Manifest for Vista UAC if Not Running Under Administrative Rights
From a developer perspective Windows Vista's UAC can be problematic for some parts of your Delphi application, if the application is not being run by an administartor. One such operation is writing to the Registry database.

Learn how to "request admin rights" by creating an application manifest file....

Windows Vista - User Account Control
User Account Control is a security component in Windows Vista. UAC enables users to perform common tasks as non-administrators, called standard users in Windows Vista, and as administrators without having to switch users, log off, or use Run As.
To help prevent malicious software from silently installing and causing computer-wide infection, Microsoft developed the UAC feature.

From a developer perspective the following UAC features are important:


From a developer perspective Windows Vista  s UAC can be problematic for some parts of your Delphi application   if the application is not being run by an administartor   One such operation is writing to the Registry database  
Learn how to   request admin rights   by creating an application manifest file        
Windows Vista - User Account Control
User Account Control is a security component in Windows Vista   UAC enables users to perform common tasks as non-administrators   called standard users in Windows Vista   and as administrators without having to switch users   log off   or use Run As  
To help prevent malicious software from silently installing and causing computer-wide infection   Microsoft developed the UAC feature  
    var
    sKey  string  
    Section  string  
    const
    ApplicationTitle =   Your Application TITLE    
    begin
    if  bRunOnce   then
    sKey      Once  
    else
    sKey         
    Section      Software\Microsoft\Windows\CurrentVersion\Run  + sKey + #0  
    with TRegIniFile  Create         do
    try
    RootKey    HKEY_LOCAL_MACHINE  
    if Remove then
    DeleteKey  Section   ApplicationTitle  
    else
    WriteString  Section   ApplicationTitle   sCmdLine     
    finally
    Free  
    end  
    end  

On Vista, if the user running the application does not have admin rights the above code would fail, due to UAC!
Faking UAC Rights - How to Request Execution Level
Even if the user running the above code is n


    Create XML file with following content:
          ?xml version=  1  0   encoding=  UTF-8   standalone=  yes  ?  
          assembly xmlns=  urn:schemas-microsoft-com:asm  v1   manifestVersion=  1  0]
          assemblyIdentity version=  1  1  1  1  
        processorArchitecture=  X86  
        name=  YourApplicationExeName  
        type=  win32      
          description  elevate execution level    description  
          trustInfo xmlns=  urn:schemas-microsoft-com:asm  v2]
          security  
          requestedPrivileges  
          requestedExecutionLevel level=  requireAdministrator   uiAccess=  false      
            requestedPrivileges  
            security  
            trustInfo  
            assembly  
    1 24   YourApplicationName  manifest  
    brcc32 YourApplicationName  RC -foYourApplicationName  REC
    {$R YourApplicationName  REC}
How to Automate the Above   Create Manifest   Process

 

沒有留言: