SEToolbox.Support.ToolboxUpdater.RunElevated C# (CSharp) Method

RunElevated() static private method

static private RunElevated ( string fileName, string arguments, bool elevate, bool waitForExit ) : int?
fileName string
arguments string
elevate bool
waitForExit bool
return int?
        internal static int? RunElevated(string fileName, string arguments, bool elevate, bool waitForExit)
        {
            var processInfo = new ProcessStartInfo
            {
                FileName = fileName,
                Arguments = arguments
            };

            if (elevate)
            {
                processInfo.Verb = "runas";
            }

            try
            {
                var process = Process.Start(processInfo);

                if (waitForExit && process != null)
                {
                    process.WaitForExit();
                    return process.ExitCode;
                }

                return 0;
            }
            catch (Win32Exception)
            {
                // Do nothing. Probably the user canceled the UAC window
                return null;
            }
        }