Visual Studio 安装程序 >如何在安装程序结束时启动应用程序
这可能是一个愚蠢的问题,我的谷歌搜索今天不起作用。
我有一个应用程序,我添加了 Visual Studio 安装程序 >设置向导项目到。我想知道如何添加一个按钮或复选框以在成功安装后启动应用程序。它位于 MSI 安装程序包的最后一页。我正在使用 Visual Studio 2010 Ultimate。
我需要这个,以便当应用程序进行自动更新时,它会自动启动安装程序。我只需要安装程序在更新后重新启动应用程序。
This is probably a stupid question and my Googling just is not functioning today.
I have an application I added a Visual Studio Installer > Setup Wizard project to. I am wondering how to add a button or check box that would launch the application after successful install. This would be located on the last page of the MSI Installer Package. I am using Visual Studio 2010 Ultimate.
I am needing this so that when the application does an automatic update, it auto launches the installer. I just need the installer to relaunch the app after the update.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
要在安装完成后运行任何应用程序,
To run any application after the installation is complete,
来自 https://blogs.msdn.microsoft.com/astebner/2006/08/12/mailbag-how-can-i-customize-an-msi-in-the-visual -studio-setupdeployment-project/
在设置末尾添加一个复选框来选择是否要启动应用程序。您可以修改默认检查的脚本...甚至隐藏它。
这里的一大优点是,应用程序不会像 Maurice Flanagan 提到的那样以更高的权限运行。
您需要的脚本是:
编辑文件以显示您想要的名称和可执行文件的名称,放
该文件位于 .vdproj 安装项目旁边,并在构建后添加以下行:
CALL cscript.exe "$(ProjectDir)EnableLaunchApplication.js" "$(BuiltOuputPath)"
The solution from https://blogs.msdn.microsoft.com/astebner/2006/08/12/mailbag-how-can-i-customize-an-msi-in-the-visual-studio-setupdeployment-project/
adds a checkbox at the end of the setup to choose if you want to start the application or not. You can modify the script to be checked by default...or even hide it.
The big advantage here is, that the application won't run with elevated rights like Maurice Flanagan mentioned.
The required script you need is:
Edit the file to show your desired name and the name of the executable, put
that file beside your .vdproj Setup project and in the postbuild add following line:
CALL cscript.exe "$(ProjectDir)EnableLaunchApplication.js" "$(BuiltOuputPath)"
在 Visual Studio 2010 中,这很容易...
第 1 步:将新的安装程序类添加到您希望在安装后运行的应用程序项目,将其命名为您喜欢的名称。
步骤2:将以下代码添加到您刚刚添加的Installer 类中,并将MyApplication.exe 替换为您的名称。
编译并运行...
In Visual Studio 2010 here it is easy...
Step1: Add a new installer class to the application project that you wish to run after install, call it what you like.
Step2: Add the following code to the Installer class you just added replcaing MyApplication.exe with the name of yours.
Compile and go...
就我而言,我为此奋斗了一段时间,解决方案就在那里。
使用自定义操作直接到应用程序主要输出提供的解决方案对我来说并不好,因为安装应用程序一直保留到您离开主应用程序为止。
因此,可以使用下一种方法解决该问题:
<块引用>
System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(this.Context.Parameters["AssemblyPath"]) + @"\MyApplication.exe")
;要了解更多信息以及我从哪里获得它,请访问 这个。
PS.:我使用VS2017和Framework 2.0制作的。
In my case, I was fighting with this for a while and the solution was just there.
The solution provided using the custom action directly to the application primary output wasn't good for me, since the install app remains until you leave the main app.
So, the issue could be solved using the next approach:
To know more about this and where I got it, please visit this.
PS.: I made it using VS2017 and Framework 2.0.
尝试查看这篇博文:
链接
我无法证明它是否适用于 2010 年;在我的 TFS 服务器升级之前,我仍然坚持使用 2008。另外,我的安装程序使用 WiX。但是,这只是一个自定义操作,所以我认为它仍然应该受到支持。
希望这有帮助!
(顺便说一句,在练习我的谷歌搜索找到这个问题时,你的问题出现在谷歌这个问题的第一页上。)
Try checking out this blog post:
Link
I can't attest for if it works for 2010 or not; I'm still stuck using 2008 until my TFS server gets upgraded. Also, I use WiX for my installers. But, it's just a custom action, so I think it should still be supported.
Hope this helps!
(By the way, while practicing my googling to find this, your question was showing up on the first page of Google for this question.)
添加另一个答案,因为之前的答案都没有解决原始帖子中的复选框或按钮问题。
您可以通过右键单击“用户界面”视图中的“开始”按钮,将其中一个固定对话框添加到您的安装项目中,例如“复选框(A)”。添加后右键单击对话框可将其上移。对于询问有关运行程序的问题,您只需要一个复选框,因此请消除其他复选框。默认属性名称为 CHECKBOXA1,因此请向自定义操作添加一个条件,以触发代码 CHECKBOXA1=1,这意味着它已被检查。
Adding another answer because none of the previous answers address the checkbox or button question in the original post.
You'd add one of the canned dialogs to your setup project, something like CheckBoxes(A) by right-clicking the Start button in the User Interface view. Right-click the dialog after adding to move it up. You need only one checkbox for the question to ask about running the program so eliminate the others. The default property name is CHECKBOXA1, so add a condition to the custom action that fires off your code CHECKBOXA1=1 meaning it was checked.
首先生成安装程序类。在那里重写安装方法。并粘贴以下命令。
first generate installer class. in that override the install method. and paste the following command.
JayTee 的剧本是最好的解决方案。
但是,脚本第一行的文件名拼写错误。
应该是以下内容:
// EnableLaunchApplication.js
按照以下链接中的说明操作时,必须使用正确的名称才能正常工作:自定义 msi
上面链接中的示例链接是错误的。
按照上述链接中的说明使用以下脚本。
JayTee's script was the best solution.
However, the file name in the first line of the script is misspelled.
It should be the following:
// EnableLaunchApplication.js <msi-file>
The correct name has to be use for it to work when following the instructions in the following link: customize msi
The sample-link in above link is bad.
Use the following script with the instructions in the above link.