Exemplo n.º 1
0
        public static void StartNewInstance(IWin32Window parent, bool requireAdmin, params string[] args)
        {
            string        str;
            StringBuilder builder = new StringBuilder();

            foreach (string str2 in args)
            {
                builder.Append(' ');
                if (str2.IndexOf(' ') != -1)
                {
                    builder.Append('"');
                }
                builder.Append(str2);
                if (str2.IndexOf(' ') != -1)
                {
                    builder.Append('"');
                }
            }
            if (builder.Length > 0)
            {
                str = builder.ToString(1, builder.Length - 1);
            }
            else
            {
                str = null;
            }
            ShellUtil.Execute(parent, Application.ExecutablePath, str, requireAdmin ? ExecutePrivilege.RequireAdmin : ExecutePrivilege.AsInvokerOrAsManifest, ExecuteWaitType.ReturnImmediately);
        }
Exemplo n.º 2
0
 public void Finish(IUpdatesServiceHost host)
 {
     if (!this.finishing)
     {
         try
         {
             if (this.haveFinished)
             {
                 throw new ApplicationException("already called Finish()");
             }
             this.finishing    = true;
             this.haveFinished = true;
             bool flag      = Security.VerifySignedFile(base.StateMachine.UIContext, this.installerPath, false, false);
             bool cancelled = false;
             host.CloseAllWorkspaces(out cancelled);
             if (flag && !cancelled)
             {
                 AppSettings.Instance.Updates.PackageFileName.Value = this.installerPath;
                 if (string.Compare(Path.GetExtension(this.installerPath), ".exe", true) == 0)
                 {
                     ShellUtil.IsActivityQueuedForRestart = false;
                     Form parent = new Form {
                         BackColor = Color.Red
                     };
                     parent.TransparencyKey = parent.BackColor;
                     parent.ShowInTaskbar   = false;
                     parent.FormBorderStyle = FormBorderStyle.None;
                     parent.StartPosition   = FormStartPosition.CenterScreen;
                     parent.Show();
                     try
                     {
                         ShellUtil.Execute(parent, this.installerPath, "/skipConfig /restartPdnOnExit", ExecutePrivilege.RequireAdmin, ExecuteWaitType.ReturnImmediately);
                     }
                     catch (Exception exception)
                     {
                         ExceptionDialog.ShowErrorDialog(parent, exception);
                     }
                     parent.Close();
                     Startup.CloseApplication();
                 }
             }
             else
             {
                 FileSystem.TryDeleteFile(this.installerPath);
             }
         }
         finally
         {
             this.finishing = false;
         }
     }
 }