【发布时间】:2016-04-04 02:34:51
【问题描述】:
在我的 C# WPF 应用程序中,我正在检查是否需要安装新版本。如果是这样,我想中断当前进程并启动安装程序。安装程序是使用 NSIS 包开发的。 问题是有时只出现来自 NSIS 安装程序的用户帐户控制对话框并且安装过程中断。
如何保证每次都执行安装过程?
这是我的应用程序启动代码。
protected override void OnStartup(StartupEventArgs e)
{
try
{
//Disable shutdown when the dialog closes
Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
if ( IfUpdateRequired())
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(sessionCtx.AutoUpdateVersionInfo.SetupPath);
//This should not block current program
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
System.Diagnostics.Process.Start(startInfo);
this.Shutdown();
}
else
{
base.OnStartup(e);
}
}
catch (Exception ex)
{
}
}
【问题讨论】:
-
你能不能加个“开始屏幕通知系统修改”的截图,因为我不太明白你在说什么。
-
我的意思是“用户帐户控制对话框”。
-
“安装过程中断”时会发生什么?是否有任何错误消息或类似的东西?
-
没有错误信息。