Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Requested operation requires elevation


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Oct 18, 2016 8:37 AM Last Post By: José Morango
Wayne Loeppky

Posts: 52
Registered: 7/4/02
Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 5:35 AM
Using XE5, Windows 8.1, small project that ran perfectly fine until yesterday now produces error "the requested operation requires elevation". If I run it as administrator it runs fine, but it never required that before and no changes made to it would require that. I did run Delphi as administrator a few days ago so I could debug something else that required the registry so wondering if that has tweaked something in this project as they do share some of the same units. If I go back to an older version of the application it runs fine as well so I know something has been tweaked in a bad way just can't figure out what it is.

Wayne
Achim Kalwa

Posts: 70
Registered: 10/22/99
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 6:03 AM   in response to: Wayne Loeppky in response to: Wayne Loeppky
Hello,

Wayne Loeppky wrote:

Using XE5, Windows 8.1, small project that ran perfectly fine until
yesterday now produces error "the requested operation requires
elevation". If I run it as administrator it runs fine, but it never
required that before and no changes made to it would require that. I
did run Delphi as administrator a few days ago so I could debug
something else that required the registry so wondering if that has
tweaked something in this project as they do share some of the same
units. If I go back to an older version of the application it runs
fine as well so I know something has been tweaked in a bad way just
can't figure out what it is.

Did you rename your application? Something with "install", "setup" or
similar in the name?

Achim
Bo Berglund

Posts: 757
Registered: 10/23/02
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 6:11 AM   in response to: Achim Kalwa in response to: Achim Kalwa
On Wed, 15 Apr 2015 06:03:43 -0700, Achim Kalwa
<delphi@achim-kalwa.de> wrote:

Hello,

Wayne Loeppky wrote:

Using XE5, Windows 8.1, small project that ran perfectly fine until
yesterday now produces error "the requested operation requires
elevation".

Did you rename your application? Something with "install", "setup" or
similar in the name?

+1
I found that an application we were maintaining also stopped running
as a normal user on Win7 and above. What had happened was that we had
updated the version information and modified the comment in that to
include one of the words Microsoft is looking for. I don't remember
exactly what it was now but something like "Data file updating
utility" or similar.
That triggered the Win7 UAC system to require elevated permissions.

So examine the version info and remove anything that even remotely
describes som real operation and then test again.

We could solve the problem by including a manifest that explicitly
states the execution permissions required.

---
Bo Berglund
Sweden & Texas
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 10:43 AM   in response to: Bo Berglund in response to: Bo Berglund
Bo wrote:

That triggered the Win7 UAC system to require elevated permissions.

That is UAC's Installer Detection feature at work, which only kicks in under
these specific conditions:

Windows Vista Application Development Requirements for User Account Control
Compatibility
https://msdn.microsoft.com/en-us/library/bb530410.aspx

Installer Detection only applies to:

- 32 bit executables
- Applications without a requestedExecutionLevel
- Interactive processes running as a Standard User with LUA enabled

So examine the version info and remove anything that even remotely
describes som real operation and then test again.

The correct solution is to include a manifest in your app that specifies
a UAC "requestedExecutionLevel" value. Then UAC will not have to analyze
your EXE to guess whether it should elevate or not. Be explicit about your
elevation requirements (or lack of). Manifests control much more than just
whether Visual Themes are enabled. From Vista onwards, Microsoft relies
more and more on manifests, they have become integral to how Windows operates
at many levels (Visual Themes, UAC/Security, DPI, COM, even basic OS compatibility).
You have to deal with manifests now, stop avoiding them.

We could solve the problem by including a manifest that explicitly
states the execution permissions required.

Yes, that is what you should do. Then you can use whatever version resource
text you want, and you can avoid UAC elevation when you don't need it.

--
Remy Lebeau (TeamB)
Wayne Loeppky

Posts: 52
Registered: 7/4/02
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 11:03 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Bo wrote:

That triggered the Win7 UAC system to require elevated permissions.

That is UAC's Installer Detection feature at work, which only kicks in under
these specific conditions:

Windows Vista Application Development Requirements for User Account Control
Compatibility
https://msdn.microsoft.com/en-us/library/bb530410.aspx

Installer Detection only applies to:

- 32 bit executables
- Applications without a requestedExecutionLevel
- Interactive processes running as a Standard User with LUA enabled

So examine the version info and remove anything that even remotely
describes som real operation and then test again.

The correct solution is to include a manifest in your app that specifies
a UAC "requestedExecutionLevel" value. Then UAC will not have to analyze
your EXE to guess whether it should elevate or not. Be explicit about your
elevation requirements (or lack of). Manifests control much more than just
whether Visual Themes are enabled. From Vista onwards, Microsoft relies
more and more on manifests, they have become integral to how Windows operates
at many levels (Visual Themes, UAC/Security, DPI, COM, even basic OS compatibility).
You have to deal with manifests now, stop avoiding them.

We could solve the problem by including a manifest that explicitly
states the execution permissions required.

Yes, that is what you should do. Then you can use whatever version resource
text you want, and you can avoid UAC elevation when you don't need it.

--
Remy Lebeau (TeamB)

Will look into this. What I don't understand is why this application was fine a week ago and now it is not. I looked at the version information, it has never been changed for this application. I went back to the other folder where I have the same application where it does work and the version information looks the same. Really puzzling that it started to behave differently for no apparent reason. Considering changing the application name to see if that has any effect.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 11:55 AM   in response to: Wayne Loeppky in response to: Wayne Loeppky
Wayne wrote:

What I don't understand is why this application was fine a week ago
and now it is not. I looked at the version information, it has never
been changed for this application. I went back to the other folder
where I have the same application where it does work and the
version information looks the same.

Many factors contribute to UAC's Installer Detection:

https://msdn.microsoft.com/en-us/library/bb530410.aspx

Before a 32 bit process is created, the following attributes are checked
to determine whether it is an installer:

- Filename includes keywords like "install," "setup," "update," etc.
- Keywords in the following Versioning Resource fields: Vendor, Company Name,
Product Name, File Description, Original Filename, Internal Name, and Export
Name.
- Keywords in the side-by-side manifest embedded in the executable.
- Keywords in specific StringTable entries linked in the executable.
- Key attributes in the RC data linked in the executable.
- Targeted sequences of bytes within the executable.

Note The keywords and sequences of bytes were derived from common characteristics
observed from various installer technologies.

Of course, this all stems from the fact that you are missing a UAC manifest
to begin with.

Really puzzling that it started to behave differently for no apparent
reason. Considering changing the application name to see if that
has any effect.

Or, simply add a manifest to your app, like you are supposed to, and the
problem will go away for good. Stop guessing, stop hunting.

Project > Options > Application > Runtime Themes > "Use custom manifest".

MyApp.exe.manifest:

<?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="*" name="MyApp" 
type="win32" />
  <description>My application description</description>
  <!-- Visual Styles -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" 
version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" 
language="*" />
    </dependentAssembly>
  </dependency>
  <!-- UAC elevation -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>    


--
Remy Lebeau (TeamB)
Wayne Loeppky

Posts: 52
Registered: 7/4/02
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 10:45 AM   in response to: Achim Kalwa in response to: Achim Kalwa
Achim Kalwa wrote:
Hello,

Wayne Loeppky wrote:

Using XE5, Windows 8.1, small project that ran perfectly fine until
yesterday now produces error "the requested operation requires
elevation". If I run it as administrator it runs fine, but it never
required that before and no changes made to it would require that. I
did run Delphi as administrator a few days ago so I could debug
something else that required the registry so wondering if that has
tweaked something in this project as they do share some of the same
units. If I go back to an older version of the application it runs
fine as well so I know something has been tweaked in a bad way just
can't figure out what it is.

Did you rename your application? Something with "install", "setup" or
similar in the name?

Achim

Never changed the application name but it does contain the word setup in the name. Odd thing is this only happens in the IDE when I run it from there. If I just compile and run it, it runs fine, but when I close the application I get the Windows Program Compatibility Assistant pop up asking whether it installed OK or not. I have two versions of the same application, the other one also compiled under XE5, it works fine. So this is really puzzling. Both applications have the same name.

Still trying to figure this out.
Achim Kalwa

Posts: 70
Registered: 10/22/99
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 2, 2015 4:46 AM   in response to: Wayne Loeppky in response to: Wayne Loeppky
Hello,

If I just compile and run it, it runs fine, but when I
close the application I get the Windows Program Compatibility
Assistant pop up asking whether it installed OK or not.

Applications without a compatibility section in their manifest will show
the Program Compatibility Assistant (PCA) if they "fail" to install
properly, i.e. their name contains "setup" or "install", but no files
are installed or no registry settings is changed during execution.

To remove the PCA message you need to include an application manifest
with a compatibility section:


Here is an excerpt from a working manifest for Vista and up:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 Technical Preview -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 / Server 2012 R2 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista / Server 2008 -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 / Server 2008 R2 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 / Server 2012 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>

HTH
Achim
Angus Robertson

Posts: 205
Registered: 3/17/00
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 6:17 AM   in response to: Wayne Loeppky in response to: Wayne Loeppky
Using XE5, Windows 8.1, small project that ran perfectly fine until
yesterday now produces error "the requested operation requires
elevation".

I had a similar issue last night after installing 1.2 Gbytes of Windows
updates on Windows 7.

One of those updates reset my User Account Control Settings from 'never
notify' to the next step up the slider, 'notify when programs try to make
changes'.

Also found I could not access the Windows backup folders without lots of
dialogs so looks like a lot of security stuff got reset, without any
warnings.

Angus
José Morango

Posts: 19
Registered: 10/2/14
Re: Requested operation requires elevation  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 18, 2016 8:37 AM   in response to: Wayne Loeppky in response to: Wayne Loeppky
Project>Options>Application>Tags to include>Mark off "Enable Administrator Privileges"
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02