0

I have to run exe file from my WPF application, but it still asking about that do I really want to open it.

System.Diagnostics.Process.Start("fileToOpen.exe", "par1 par2");

Is there any way to open file without the UAC Permission window displaying?

Rudi Visser
  • 21,350
  • 5
  • 71
  • 97
user13657
  • 745
  • 3
  • 17
  • 36
  • What question window? Can you show it to us? – Emond May 17 '13 at 09:10
  • If the application `fileToOpen.exe` requires elevation and your application doesn't have it when you try to start it, you're going to get the window regardless. The best solution is to make *your* application require elevation, and any future execution requests won't popup. – Rudi Visser May 17 '13 at 10:02
  • [FAQ: Why can’t I bypass the UAC prompt?](http://blogs.msdn.com/b/aaron_margosis/archive/2007/06/29/faq-why-can-t-i-bypass-the-uac-prompt.aspx) – Bill_Stewart May 21 '13 at 02:38

1 Answers1

2

Depending on end customer I don't recommend this at all; you're going against the systems security, if they have the UAC on, it's for a reason. You're creating security risks (as I'm sure you already know).

Anyway, a few work arounds:

Assuming you want to ensure it never comes on and based upon your comments on other answers then yes, you can do this as per the following SO post: Disabling UAC programmatically

Set the EnableLUA DWORD value in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System to 0 and reboot.

The problem is, this disables it totally and (depending on end customer) may be very undesired.

Another solution is (from same source):

You can't programmatically disable UAC, but you can force the program to run with elevated privileges from the start, so it doesn't prompt each time. That will cause it to prompt once on startup, but not each time it needs access. To do this, you'll need to create a manifest file and set

After reading up more on this, it appears you're better off testing for it instead of your initial thoughts (disabling/ignoring/prevention). Again, see this post Selectively disabling UAC for specific programs on Windows Programatically

Community
  • 1
  • 1
Dave
  • 8,163
  • 11
  • 67
  • 103
  • 1
    Wouldn't a regedit start call an UAC prompt itself (atleast once)? – jAC May 17 '13 at 09:19
  • @JanesAbouChleih, *as long as you are running the program (exe) under admin (ie person running app has accepted to run it as admin) then you actually can do the registry trick without the user being told anything, in VISTA, in Win7, you can still do it, but user will get notification saying 'you need to restart your computer in order for UAC to take effect'* (from source); the situation is totally not ideal. The point of the UAC is it is controlled by the user. My answer is more about work arounds! – Dave May 17 '13 at 09:21
  • @DaveRook: Yep, not ideal, but as I see this is really the only way. So +1 – jAC May 17 '13 at 09:27