msi 安装后运行 exe,我看到启动复选框,但应用程序未运行
我正在使用此答案 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();
}
I am using the script from this answer https://stackoverflow.com/a/1681410/22 to insert a launch application checkbox at the end of the MSI installer.
Everything builds ok and I get the launch checkbox just fine, however the application does not launch when the installer is complete.
Not sure if this is the cause but my app does require admin (app.manifest)
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Installer Build Output:
------ 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
Edit:
If I right click the setup project in Visual Studio and select "Install". The app runs when the installer closes.
However, if I just double click the generated MSI. The app will not open after the MSI closes.
I've also tried to change the custom action to this, but I still get the same results:
sql = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('VSDCA_Launch', '226', 'TARGETDIR', '[TARGETDIR]\\MyApp.exe')";
Update:
I ended up using a slightly modified version of "DJ KRAZE" answer. In my Main method I check for a "frominstaller" argument and then just launch the app in a new process and exit. Which then allows the installer to continue normally. Then I add the exe in the "Install" custom action with the "/frominstaller" argument.
if (frominstaller)
{
Process p = new Process();
p.StartInfo.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
p.Start();
Application.Exit();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过您引用的链接中的帖子中列出的这些步骤?
要在安装完成后运行任何应用程序,请右键单击您的安装项目,然后单击“自定义操作”。然后右键单击“提交”,“添加自定义操作”,然后选择您要运行的文件。请注意,它必须已经位于您的应用程序文件夹中,这对于您的情况来说应该不是问题,因为无论如何您都在运行您的程序。只需选择项目的输出即可。
然后,单击添加的 .exe,并将 InstallerClass 更改为 false。这很重要,因为否则它将寻找安装程序。
您甚至可以通过将参数添加到 Arguments 属性来将参数传递给 .exe
Have you tried these steps as listed in the post from the link that you referenced..?
To run any application after the installation is complete, right-click on your setup project, click on Custom Actions. Then right-click on Commit, Add Custom Action, and choose the file you would like to run. Note that it has to be in your application folder already, which shouldn't be a problem in your case since you are running your program anyway. Simply choose the output of your project.
Then, click on this added .exe, and change InstallerClass to false. This is crucial because it will look for an installer program otherwise.
You could even pass parameters to your .exe by adding them to the Arguments property