重启系统后如何解决卸载窗口问题?

时间:2016-07-14 04:44:34

标签: c#

我尝试安装使用Wix installer开发的exe。安装完成后,尝试重新启动系统。我使用了以下示例逻辑。

示例:

        private void btn_RestartYes_Click(object sender, RoutedEventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(RestartThreadFunction));
            thread.Start();
            this.Close();
            SyncBA.Model.Engine.Quit(0);

        }
        public void RestartThreadFunction()
        {
            try
            {
                Process.Start("shutdown", "/r");
            }
            catch (Exception ex)
            {
                SyncBA.Model.Engine.Log(LogLevel.Error, ex.Message);
            }
        }

        private void btn_RestartLater_Click(object sender, RoutedEventArgs e)
        {
            this.Close();

        }
                                  ( OR )


       private void btn_RestartYes_Click(object sender, RoutedEventArgs e)
        {
            RestartThreadFunction();          

        }
        public void RestartThreadFunction()
        {
            try
            {
                ProcessStartInfo proc = new ProcessStartInfo();
                proc.WindowStyle = ProcessWindowStyle.Hidden;
                proc.FileName = "cmd";
                proc.Arguments = "/C shutdown -f -r";
                Process.Start(proc);
                SyncBA.Model.Engine.Quit(0);
                this.Close();
            }
            catch (Exception ex)
            {
                SyncBA.Model.Engine.Log(LogLevel.Error, ex.Message);
            }
        }
    private void btn_RestartLater_Click(object sender, RoutedEventArgs e)
    {
        this.Close();

    }
  

以上逻辑成功运作正常。重新启动系统" exe"卸载窗口出现。

重启系统后如何解决卸载窗口问题?

提前致谢!!

0 个答案:

没有答案