Run as Administrator right after update under Win10 RRS feed

  • Question

  • Hello!

    Since Win10's been issued, some of my clients, who uses my software and done the update up to Win10 (actually not many of them did that, as they assumed Win10 as the OS that has generally been written for Tab PCs :)
    Anyway, I've noticed that when they use my own update mechanism (update.exe) over the Internet network, the right "Run As Administrator", that is assigned to EXE assembly by genesis after it's built and that is automatically inherited with Windows Installer by its Desktop Label during setup process, is reset after this EXE is replaced with the fresh one and only under Win10.
    So now, while Win7 checks the Label for that right and it's enough, the Win10 checks both and drops that right if exe is replaced.

    So, to overstep that problem, I am looking for a way how to assign  this right to the EXE module from outside, with the "update.exe" program?

    "I = I + 1" .. Isn't it boolshit?

    Monday, November 25, 2019 5:41 PM

All replies

  • run as admin isn't a right. It is a verb (runas). If your update program can only work as administrator, you should write <requestedExecutionLevel level="requireAdministrator"/> in your application manifest. The application manifest  can be embedded as a resource (you embed it to your exe using mt.exe from Windows SDK) or as an external XML file that has the same file name with your updater executable but with an exe.manifest extension.

    Without the manifest Windows would try to detect whether a 32 bit process is installer or not, using common characteristics of installer technologies. But the user could also have the User Account Control: Detect application installations and prompt for elevation setting disabled. This installer detection is there to minimize compatibility issues, not for trying to guess everything right, or force the guessing on to the user.

    Visual C++ MVP

    Monday, November 25, 2019 8:21 PM
  • Thanks for your participation, but I've asked not about how to assign that right to an exe module, I know how to do that since maybe 2008. 
    My Q was about some changes under W10, and I explained maybe not clear, not easy to write about that, but in short - the grant "RunAsAdmin", that's assigned after installation, is deleted in some system tables after the exe module was replaced by update.exe (and !!! they both compiled with that option in manifest).
    It happens only since W10. So if you personally haven't met this situation, it is hard to explain what it is, I am expecting to meet here a someone who's also met that new behavior and to discuss how to overstep it.
    Maybe the Defender is responsible for that?
    To moderators, if this Q is not related to C#, then, please, remove it or relocate to the thread list.. with the relatively correct subject..

    "I = I + 1" .. Isn't it boolshit?

    Tuesday, November 26, 2019 9:45 AM
  • If the executable has a properly-formatted manifest, then Windows should show the elevation dialog when you run the app.  There is no other "hidden state".  For apps without a manifest, the "Run As Administrator" setting in the Properties dialog is stored in the registry in HKCU\Software|Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Tuesday, November 26, 2019 11:33 PM
  • Hi RobbKirk, 

    Thank you for posting here.

    According to your description, your issue is more related to Windows 10. Therefore, it will be more appropriate to ask your question in Windows 10 Forums.

    The C# forum is for C# related question, we discuss and ask the C# programming language, IDE, libraries, samples and tools here.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 27, 2019 7:58 AM