是否可以從自定義操作中正常退出msi installar?停止自定義操作的安裝
我使用Visual Studio安裝項目來創建msi,並且我添加了一個自定義動作exe來安裝。如果我從exe中返回非零值,它會終止安裝。但它顯示一個錯誤。我需要退出安裝而不顯示錯誤。
謝謝。
是否可以從自定義操作中正常退出msi installar?停止自定義操作的安裝
我使用Visual Studio安裝項目來創建msi,並且我添加了一個自定義動作exe來安裝。如果我從exe中返回非零值,它會終止安裝。但它顯示一個錯誤。我需要退出安裝而不顯示錯誤。
謝謝。
最後我找到了一種方法來使用從http://chensuping.blogspot.com/2013/05/windows-setup-project-vbs-custom-action.html的vbscript自定義操作。
試試這個代碼在你的安裝程序類。我希望它能解決你的問題。
protected override void OnBeforeInstall(IDictionary savedState)
{
if (LaunchOnBeforeInstall())
{
base.OnBeforeInstall(savedState);
}
else
{
throw new Exception("You cancelled installation");
}
}
public bool LaunchOnBeforeInstall()
{
Form2 frm2 = new Form2();
DialogResult result = frm2.ShowDialog();
if (result == DialogResult.Cancel)
{
return false;
}
else
{
return true;
}
}
而且也把「NOTPREVIOUSVERSIONSINSTALLED」