我有一个自定义安装程序类的安装项目,它在安装结束时启动应用程序。在设置中,我创建了应用程序输出的快捷方式。安装没问题。但是当我点击快捷方式时,安装程序将重新启动并且应用程序同时启动?为什么?C#安装项目中的快捷方式问题
不,我的自定义类的代码是:
/// <summary>
/// Installer class to automatically launch the application at the end of the installation/
/// </summary>
[RunInstaller(true)]
public partial class InstallerStartApplication : Installer
{
/// <summary>
/// Initializes a new instance of the <see cref="InstallerStartApplication"/> class.
/// </summary>
public InstallerStartApplication()
{
InitializeComponent();
}
/// <summary>
/// Raises the <see cref="E:System.Configuration.Install.Installer.AfterInstall"/> event.
/// </summary>
/// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after all the installers contained in the <see cref="P:System.Configuration.Install.Installer.Installers"/> property have completed their installations.</param>
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
}
// Override the 'Install' method.
public override void Install(IDictionary savedState)
{
base.Install(savedState);
}
// Override the 'Commit' method.
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
try
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "IERssNotificator.exe"), "-c");
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
// Override the 'Rollback' method.
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
}
我推出这个在安装和提交自定义操作。
不,请参阅我的代码...以上 – Coolweb
有什么办法让它创建一个* normal *快捷键而不是触发安装程序的排序? –
我没有找到它。最后,我使用WinAPI在Commit操作中创建了快捷方式。您可以使用WScript.Shell或http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp库 –