c# - Process.Start never returns when UAC denied -


I have an updater exe whose primary axis is to be closed, replace it with an updated exe, and then update The program file was done. When the updater has tried to start an updated exe, if the UAC permissions have been rejected by the user, the updater will hang. This is because process. The start () function never returns. My CPU cycle meter indicates practically any use of BTID.

I hope all my users are called "yes" to UAC, but since I am here, I would like to handle this matter in some way, at least in the error message, assume that my users There will be at least 7 windows. XS itself has 32 bit Winform applications. Targeted Net Framework 4.0 is Using Visual Studio 2010 Ultimate.

How has my user detected the UAC dialog to reject?

I think that what I can do is process the . Start () running on a separate thread which will be timeout after a while. For more code:

  Private Zero RestartProcess () {ProcessStartInfo startInfo = new ProcessStartInfo (); StartInfo.FileName = @ "C: \ Users \ me \ Document \ Visual Studio 2010 \ Projects \ updated.exe"; MessageBox.Show ("attempt to start the process"); Process New Process = Process Start (startInfo); MessageBox.Show ("If this is known, the user has clicked on the UAC."); }  

Solution:

Process. Start () Exits quietly with a Win32Exception until blocking {{catcher}} try to catch error.

  process newProc = Process.start (startInfo); MessageBox.Show ("If this is known, the user has clicked on the UAC.");  

This is normal, exceptions raised by Process.Start () will bypass MessageBox.Show () call. This is Win32Exception for Windows error code 1223, ERROR_CANCELLED, "Operation was canceled by user"

Obviously you want to avoid swallowing exceptions.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -