11

I am building a tool which allows to install an application into our simulator and it is called 'cl-install.exe'. It really doesn't need any administrator privileges to run. But Windows 7 always pops up a dialog asking the user to provide administrator privileges when this command is invoked from the command prompt.

If I rename the same executable to some other name, without the words 'install' or 'setup' in it, Windows doesn't ask for admin privileges.

Is there any way I can prevent Windows from doing this, without renaming my executable?

1

3 Answers 3

14

This is part of the heuristics present in Windows Vista and later. From here if the file contains the words "install", "setup", "update" or "patch" - installer is assumed.

You can prevent this by adding the following to your manifest

<requestedExecutionLevel level="asInvoker" />
4
  • 2
    I love this site. I learn 10 new things every day. Thanks for your answer.
    – GrayFox374
    Jul 20, 2012 at 5:49
  • I created a file called 'cl-install.exe.manifest' in the same directory as my executable and added the line you have given. When running the file now, I get something like: "The application has failed to start because its side-by-side configuration is incorrect...". My executable is not an installer. It is a simple custom utility built with MinGW GCC.
    – arunkd13
    Jul 20, 2012 at 11:48
  • You need to properly embed the manifest in your executable. Hopefully a search of stackoverflow will help you work out how to do this in MinGW, if not, ask a new question. Jul 20, 2012 at 22:50
  • Sorrt, I actually chickened out and changed my executable name a little. Anyway, thanks for the pointer.
    – arunkd13
    Aug 30, 2012 at 9:38
5

I've found a working solution here: https://github.com/bmatzelle/gow/issues/156

Quote:

The solution is to write a manifest file listed below for the executables, in order to persuade UAC that it does not require administrative privilege.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <!-- Make sure that UAC believes
        that it does not require administrative privilege -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

The filenames of the manifest files should be install.exe.manifest and patch.exe.manifest, and then put them in the same folder as install.exe and patch.exe.

If the UAC prompt still pops up, change the timestamp of install.exe and patch.exe to persuade Windows to pick up the new manifest file.

2

If I remember correctly you can disable this behaviour the following way (quoted from Technet):

  1. Click Start, click All Programs, click Accessories, click Run, type secpol.msc in the Open text box, and then click OK.

  2. From the Local Security Settings console tree, click Local Policies, and then click Security Options.

  3. Scroll down and double-click User Account Control: Detect application installations and prompt for elevation.

  4. Select the Disabled option, and then click OK.

  5. Close the Local Security Settings window.

You may need to re-logon for the setting to take effect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.