Vista (x86) running the VC program as an administrator

Source: Internet
Author: User
Tags resource xmlns

Method one, (http://topic.csdn.net/u/20070303/15/457ee919-8a0b-46c4-9dd7-8606631e2108.html)

In the EXE project to find the last line in manifest before adding the following code: to compile on it,

<ms_asmv3:trustinfo   xmlns:ms_asmv3= "Urn:schemas-microsoft-com:asm.v3" >  
        <ms_asmv3:security   xmlns:ms_asmv3= "Urn:schemas-microsoft-com:asm.v3" >  
                <requestedPrivileges>  
                          < requestedExecutionLevel   level= "requireadministrator"   uiaccess= "false" >     </ requestedexecutionlevel>  
                </requestedPrivileges>  
        </ms_asmv3:security>  
</ms_ Asmv3:trustinfo>

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/vc/

However, such EXE only run administrator rights, if the general user login, you need to enter the administrator's account number and password to do. Generally is not set requireadministrator, but set it as asinvoker.

However, in some not patched XP SP2 system, the use of manifest elevated permissions may cause the system to reboot, use caution!

The VC6 is as follows: (http://blog.csdn.net/wangyong0921/archive/2008/01/21/2057662.aspx

http://www.debugman.com/read.php?tid=325)

<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?> <assembly "xmlns=
": Asm.v1 "manifestversion=" 1.0 ">
<assemblyidentity
    version=" 1.0.0.0 "processorarchitecture=" X86
    "
    name=" test.exe.manifest "
    type=" Win32 "/> <trustinfo xmlns=
" urn:schemas-microsoft-com: Asm.v3 ">
    <security>
        <requestedPrivileges>
            <requestedexecutionlevel level=" Requireadministrator "uiaccess=" false "/>
        </requestedPrivileges>
    </security>
</ Trustinfo>
</assembly>

The code is added to the VC resource and can be added in the following ways:

Add a "Custom" resource, "Resource type", fill in 24, change the resource ID to 1

If you have only one executable file, you can add it in the following ways:

Mt.exe-manifest e4nmgr.exe.manifest-outputresource:e4nmgr.exe;1

Method two, (http://topic.csdn.net/u/20070303/15/457ee919-8a0b-46c4-9dd7-8606631e2108.html)

For example, I changed D:\BitSpirit\BitSpirit.exe to admin privileges.

HKEY_CURRENT_USER\Software\Microsoft\Windows Nt\currentversion\appcompatflags\layers

Add a String key value:

The name is set to "D:\BitSpirit\BitSpirit.exe"

Numeric data is set to "RunAsAdmin"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.