0

I am really struggling finding a solution for running my c# WPF application as a standard user. I get a UAC dialog which pops up and asks for a User Name and Password.

Here is what I have done so far.

  • Added a Manifest file to the application to the application with the following level. Also tried highestAvailable

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

  • Stripped back my application of anything that I thought may trigger the issue as previously it was writing Log Files (Log4Net) to a LogFiles directory under Program Files\My Application. The standard user does have access to the application directory (used to test as that user can create files and directories). For now I have no text file logging. I was also writing to the HLCU registry key but I have taken all of that out for testing even though I believe HKCU should not trigger the prompt.

  • Checked my application names etc for instances like setup, installer etc based on the reading I did on Heuristics Checks. All Fine.

The application is pretty stock standard. C# WPF Net Framework 4.5.1 DevExpress. Functionality is pretty much just a GUI that accesses a MySQL database and communicates with a Service on the network via TCP.

The one thing that is really strange is if I go into the .exe.config file of the application, put a space somewhere then save the file, When I open the application I don't get the UAC prompt. Restart the PC and log in as that user and I get the UAC Prompt. Cancel the prompt, run again and Get Prompt again (testing). Edit the config file again, put a space and then backspace and save. I open the application and I don't get a UAC prompt.

Its really starting to drive me nuts.

If anyone has any tips or pointers, it would be muchly appreciated.

Thanks,

Daniel.

  • Did you see this answer here? https://stackoverflow.com/a/5276770/507950 – dodgy_coder Feb 29 '20 at 12:21
  • 1
    Unless they're still using xp, a user cannot change anything in program files. Uac will stop them writing anything there, including log files, config or settings your code is trying to write. Anything like that, put it in appdata.https://social.technet.microsoft.com/wiki/contents/articles/30915.c-local-files.aspx – Andy Feb 29 '20 at 13:51
  • Yes, I have looked at that other response but dont want or need to run as administrator. I have removed everything from the Program Files Directory but the issue still remains. I will attempt to move the app.config file to outside of program files and see if this resolves the issue – Daniel Kelly Feb 29 '20 at 19:36

1 Answers1

0

If you have indeed correctly added the entry to your application's manifest:

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

then the only explanation is the execution level of the application is cached; and a reboot will clear it.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219