-1

I am developing a portable application (no install) that needs administrator privileges to work properly, and I want it to run as administrator automatically so that the user doesn't have to. In the app.manifest file, I changed modified the requestedExecution level from asInvoker to highestAvailable:

<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

(I also tried requireAdministrator)

And indeed, now my application always launches as administrator automatically. When I go to my debug folder ([application folder]/bin/debug), and run the .exe directly, it also launches as administrator by default. Even if I copy it to some other folder on my computer, all is good. The .exe even has that typical administrator sign on it's icon.

Unfortunately, when I sent my application to my friend, he reported that my application does not launch as administrator automatically, and there is no administrator sign on the application icon either. I have tried to find what the cause could be, to no avail. I am not even sure what information to provide with this question, as I have no idea what could be relevant in this case. As I understand it, the app.manifest is automatically included in the .exe file. There is an app.manifest file in the [application folder]/My Project folder, but even if I delete it from there, my application .exe still runs as administrator, so I guess manifest gets compiled into exe during build.

Can anyone please suggest what could be the cause here? If there's any more info needed that I didn't know to include, please do tell.

1 Answers1

0

The reason being that you are building the solution in debug mode. Please change from debug to Release and then rebuild. That should do the trick, as it worked for me. It will be located in ([application folder]/bin/release).

  • Thank you for your answer. I built it as a Release, but my friend reported that it still launches without administrator privileges... – Justinas Rubinovas Apr 18 '19 at 08:59
  • @JustinasRubinovas on your friends computer does it show the little windows shield? –  Apr 18 '19 at 13:05
  • No, it doesn't, which is especially strange. I tried sending my exe packed in a .zip, thinking that maybe the application gets somehow altered during sending (by browser or antivirus) as a security measure, but unfortunately, no matter how that exe ends up on his computer, it doesn't have the little windows shield. – Justinas Rubinovas Apr 18 '19 at 13:07
  • @JustinasRubinovas Could very well be the version of windows he is running. Please read this. [Windows 7 N](https://support.microsoft.com/en-us/help/11529/what-is-a-windows-7-n-edition) –  Apr 18 '19 at 13:14
  • yeah, I did investigate it, but I can't seem to find anything particular about this Windows version that would be relevant to the issue. Some other people above commented that this might have to do something with UAC being disabled on that computer, which is why Windows doesn't ask if my exe should really be run as administrator, and therefore runs it as non-admin by default. I hope there is some way to automatically force my exe to be launched as admin regardless of this. – Justinas Rubinovas Apr 18 '19 at 13:18
  • @JustinasRubinovas Maybe do a check to see if the User has UAC enabled. Other than that I don't really know how to help as I have never ran into this problem. I am sorry –  Apr 18 '19 at 13:26
  • Well, I can add that check, as well as check if the application was successful in launching itself as administrator, but what I want to do is to force it to launch as administrator, not make a message box that it failed... – Justinas Rubinovas Apr 18 '19 at 14:14