简体   繁体   English

Wix - 从安装目录安装后如何运行 exe 文件?

[英]Wix - How to run exe files after installation from installed directory?

I'm using a program which is being installed using wix.我正在使用一个使用 wix 安装的程序。 (Don't know if it's relevant but it's a C# program) (不知道它是否相关,但它是一个 C# 程序)

I want to run an exe file which was installed by the msi file, but the location of the installation is unknown to me since the user chooses the installation path.我想运行一个由msi文件安装的exe文件,但是由于用户选择了安装路径,所以我不知道安装的位置。

I wanted to ask for example of how to run an exe file from the location the user chooses.我想问例如如何从用户选择的位置运行 exe 文件。

Even though it's not a part of the question, I would also be glad to see some example of running an exe file from an absolute location since I'm a beginner to wix and doing it all for the first time.即使这不是问题的一部分,我也很高兴看到一些从绝对位置运行 exe 文件的示例,因为我是 wix 的初学者,并且是第一次这样做。

The Isaiah4110 answer is not the best way if you don´t need a UI.如果您不需要 UI,Isaiah4110 答案不是最好的方法。

The simplest way to execute the exe file target you are installing through the MSI file produced by Wix is with a custom action type 18 (identifying the action by FileKey), here you are a complete example:通过 Wix 生成的 MSI 文件执行您正在安装的 exe 文件目标的最简单方法是使用自定义操作类型 18(通过 FileKey 识别操作),这里是一个完整的示例:

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Id="TargetProgram" Guid="f757ff43-0266-483a-8749-ec796cba4b25" >
    <File Id="EXE" Source="C:\SetupProject\Includes\TargetProgram.exe" />
  </Component>
</ComponentGroup>

<CustomAction Id="EXECUTE_AFTER_FINALIZE"                  
              Execute="immediate" 
              Impersonate="no"
              Return="asyncNoWait"
              FileKey="EXE"
              ExeCommand="" />

<InstallExecuteSequence>
  <Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
</Fragment>

This can be achieved with the help of the WIX Extensions.这可以在 WIX 扩展的帮助下实现。 The bold/italic text below will handle the case of finding the exact location of your EXE :)下面的粗体/斜体文本将处理查找 EXE 的确切位置的情况:)

Step 1: Add the extension libraries to your project第 1 步:将扩展库添加到您的项目中

If you are using WiX on the command-line you need to add the following to your candle and light command lines:如果您在命令行上使用 WiX,则需要将以下内容添加到蜡烛和灯光命令行中:

-ext WixUIExtension -ext WixUtilExtension

If you are using Visual Studio you can add the extensions using the Add Reference dialog:如果您使用的是 Visual Studio,则可以使用“添加引用”对话框添加扩展:

Right click on your project in Solution Explorer and select Add Reference...
Select the WixUIExtension.dll assembly from the list and click Add
Select the WixUtilExtension.dll assembly from the list and click Add
Close the Add Reference dialog

Step 2: Add UI to your installer第 2 步:将 UI 添加到您的安装程序

The WiX Minimal UI sequence includes a basic set of dialogs that includes a finished dialog with optional checkbox. WiX Minimal UI 序列包括一组基本对话框,其中包括带有可选复选框的完成对话框。 To include the sequence in your project add the following snippet anywhere inside the <Product> element.要将序列包含在您的项目中,请在<Product>元素内的任何位置添加以下代码段。

<UI>
    <UIRef Id="WixUI_Minimal" />
</UI>

To display the checkbox on the last screen of the installer include the following snippet anywhere inside the <Product> element:要在安装程序的最后一个屏幕上显示复选框,请在<Product>元素内的任何位置包含以下代码段:

<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name" />

The WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT property is provided by the standard UI sequence that, when set, displays the checkbox and uses the specified value as the checkbox label. WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT 属性由标准 UI 序列提供,设置后,显示复选框并使用指定的值作为复选框标签。

Step 3: Include the custom action第 3 步:包括自定义操作

Custom actions are included in a WiX project using the <CustomAction> element.使用<CustomAction>元素将自定义操作包含在 WiX 项目中。 Running an application is accomplished with the WixShellExecTarget custom action.运行应用程序是通过 WixShellExecTarget 自定义操作完成的。 To tell Windows Installer about the custom action, and to set its properties, include the following in your project anywhere inside the <Product> element:要将自定义操作告知 Windows 安装程序并设置其属性,请在项目中<Product>元素内的任何位置包含以下内容:

<Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

The Property element sets the WixShellExecTarget to the location of the installed application. Property 元素将 WixShellExecTarget 设置为已安装应用程序的位置。 WixShellExecTarget is the property Id the WixShellExec custom action expects will be set to the location of the file to run. WixShellExecTarget 是 WixShellExec 自定义操作期望将设置为要运行的文件位置的属性 ID。 *** ***

The Value property uses the special # character to tell WiX to look up the full installed path of the file with the id myapplication.exe. Value 属性使用特殊的 # 字符告诉 WiX 查找 ID 为 myapplication.exe 的文件的完整安装路径。


The CustomAction element includes the action in the installer. CustomAction 元素包括安装程序中的操作。 It is given a unique Id, and the BinaryKey and DllEntry properties indicate the assembly and entry point for the custom action.它被赋予一个唯一的 Id,BinaryKey 和 DllEntry 属性指示自定义操作的程序集和入口点。 The Impersonate property tells Windows Installer to run the custom action as the installing user. Impersonate 属性告诉 Windows Installer 以安装用户的身份运行自定义操作。

Step 4: Trigger the custom action第 4 步:触发自定义操作

Simply including the custom action, as in Step 3, isn't sufficient to cause it to run.仅包含自定义操作(如步骤 3 中所示)不足以使其运行。 Windows Installer must also be told when the custom action should be triggered.还必须告知 Windows Installer 何时应该触发自定义操作。 This is done by using the <Publish> element to add it to the actions run when the user clicks the Finished button on the final page of the UI dialogs.这是通过使用<Publish>元素将其添加到用户单击 UI 对话框最后一页上的 Finished 按钮时运行的操作来完成的。 The Publish element should be included inside the <UI> element from Step 2, and looks like this: Publish 元素应包含在步骤 2 中的<UI>元素中,如下所示:

<Publish Dialog="ExitDialog"
    Control="Finish" 
    Event="DoAction" 
    Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>

The Dialog property specifies the dialog the Custom Action will be attached to, in this case the ExitDialog. Dialog 属性指定自定义操作将附加到的对话框,在本例中为 ExitDialog。 The Control property specifies that the Finish button on the dialog triggers the custom action. Control 属性指定对话框上的完成按钮触发自定义操作。 The Event property indicates that a custom action should be run when the button is clicked, and the Value property specifies the custom action that was included in Step 3. The condition on the element prevents the action from running unless the checkbox from Step 2 was checked and the application was actually installed (as opposed to being removed or repaired). Event 属性指示应在单击按钮时运行自定义操作,Value 属性指定包含在步骤 3 中的自定义操作。元素上的条件阻止操作运行,除非选中了步骤 2 中的复选框并且实际安装了应用程序(而不是被删除或修复)。

Check this link for details.查看此链接了解详情。 How to run exe after install . 安装后如何运行exe I copied it here for the benefit of others looking for the same answer.我将其复制到此处以供其他寻求相同答案的人使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用WIX.sharp安装服务后如何运行exe文件(我的目标-为服务创建msi)? - How to run exe file after installation servise with WIX.sharp (My objective - create msi for service)? 如何在 Wix 安装程序中指定安装目录路径 - How to specify an installation directory path in Wix Installer 如何将[ConsoleAppName] .exe.config包含到wix安装中 - How to include [ConsoleAppName].exe.config to wix installation 如何通过wix安装程序中的自定义操作设置安装目录? - How can I set the installation directory from a custom action in my wix installer? WiX Toolset PermissionEx问题-安装后应用无法运行 - WiX Toolset PermissionEx Problem - App Does Not Run After Installation 安装第一个.exe后,如何制作一个包含两个.exe文件和第二个.exe文件的.exe文件将自动移至启动文件夹。 - How to make one .exe file which contain two .exe files and second will be automatically move to the Startup folder after Installation of First .exe 执行时安装文件后的Wix自定义操作dll - Wix custom-action dll after files installed at execution 从已安装的 Window 服务使用 UI 运行 exe - Run exe with UI from installed Window service 在安装wix安装程序的过程中如何复制folder / files1..to..files5 - How to copy folder/files1..to..files5 during the installation of wix installer WiX:如何访问/更改托管引导程序中的安装目录? - WiX: how to access / change installation directory in managed bootstrapper?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM