【发布时间】:2012-02-14 13:54:51
【问题描述】:
我正在使用此答案 https://stackoverflow.com/a/1681410/22 中的脚本在 MSI 安装程序的末尾插入一个启动应用程序复选框。
一切正常,我得到启动复选框就好了,但是安装程序完成后应用程序没有启动。
不确定这是否是原因,但我的应用确实需要管理员 (app.manifest)
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
安装程序构建输出:
------ Starting pre-build validation for project 'MyAppInstaller' ------
------ Pre-build validation for project 'MyAppInstaller' completed ------
------ Build started: Project: MyAppInstaller, Configuration: Release ------
Building file 'C:\path\to\MyAppInstaller.msi'...
Packaging file 'MyApp.exe'...
Packaging file 'Icon.ico'...
Starting post-build events...
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Updating the Control table...
Updating the ControlEvent table...
Updating the CustomAction table...
Updating the Property table...
Done Adding Additional Store
Successfully signed: MyAppInstaller.msi
编辑:
如果我在 Visual Studio 中右键单击安装项目并选择“安装”。安装程序关闭时应用程序运行。
但是,如果我只是双击生成的 MSI。 MSI 关闭后应用将无法打开。
我也尝试将自定义操作更改为此,但我仍然得到相同的结果:
sql = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('VSDCA_Launch', '226', 'TARGETDIR', '[TARGETDIR]\\MyApp.exe')";
更新:
我最终使用了“DJ KRAZE”答案的略微修改版本。在我的 Main 方法中,我检查“frominstaller”参数,然后在新进程中启动应用程序并退出。然后允许安装程序正常继续。然后我使用“/frominstaller”参数在“安装”自定义操作中添加 exe。
if (frominstaller)
{
Process p = new Process();
p.StartInfo.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
p.Start();
Application.Exit();
}
【问题讨论】:
-
您尝试运行的文件是否已确定安装在目标机器上?
-
这是构建器安装程序的输出。安装本身在哪里?
-
gbianchi - 我在哪里可以找到?
-
Tom - 是的,我可以在安装后从桌面快捷方式启动它。
标签: c# .net visual-studio installation windows-installer