[英]Launch after installation
我有一個自動更新的應用程序,當有新的更新時,我通過ftp下載installer.msi,我無聲安裝並關閉了該應用程序,我想知道如何在安裝成功后重新啟動該應用程序。
我找到了一些有關它的主題,但是似乎沒有任何用處,因為有不同的錯誤(錯誤的軟件包,錯誤1001等)。
我認為在安裝程序的提交上添加輸出的方法是一種不錯的方法,但我無法使其正常工作,有什么想法嗎?
提前致謝
這對我有用:
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(IDictionary savedState)
{
savedState.Add("InstallDir", Context.Parameters["dir"]);
base.Install(savedState);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
Start(savedState);
}
private void Start(IDictionary savedState)
{
try
{
string DirPath = (string)savedState["InstallDir"];
if (!string.IsNullOrEmpty(DirPath))
{
Process.Start(DirPath + @"\WindowsFormsApplication1.exe");
}
}
catch
{
}
}
}
您必須為Install
操作的CustomActionData
定義/dir="[TARGETDIR]\\"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.