![](/img/trans.png)
[英]WIX Toolset - Custom Action command doesn't correctly detect Windows 10 version
[英]WiX:Call Custom Action, console command with a parameter
平台:(开发中)Windows 7 x64,Wix 3.10(但该安装程序可能仅用于服务器操作系统)
我想在Wix msi安装程序窗口中使“下一步”按钮调用带有参数的控制台命令DISM(SxS文件夹的路径,请参阅我以前的文章):
WiX Cannot input session value to a text box (with CustomAction)
https://stackoverflow.com/questions/48259260/wix-cannot-input-session-value-to-a-text-box-with-customaction
如果我理解正确(请问是否有任何错误,您可以修改下面的条件吗?):1)“定制操作”表中定义的Windows msi安装程序中有CustomAction类型:
CustomAction Table
https://msdn.microsoft.com/ja-jp/library/aa368062.aspx
如果我想为console命令设置参数并调用console命令(可能使用管理员帐户),我必须通过使用Wix Custom Action element标签中的某些参数来选择某种类型(50?),对吗? (我想我不能明确选择一种类型的msi自定义操作...)
CustomAction Element
http://wixtoolset.org/documentation/manual/v3/xsd/wix/customaction.html
2)我想在按下“下一步”按钮后立即使用CustomAction Execute:“立即”使用,但是我担心立即的Custom Action无法以提升的状态调用它((如果没有Administrator特权,DISM命令可能无法使用。) 。)我将尝试获取错误,但是如果我在筋疲力尽之前应该更改为Execute:“ deferred”,请告诉我。 (我认为右键单击“以管理员身份运行”的msi可能不是问题。)
WIX CUSTOM ACTION CALL AFTER NEXT
https://stackoverflow.com/questions/17227368/wix-custom-action-call-after-next
WIX: How to run application with parameters from custom action?
https://alexanderst.wordpress.com/2010/10/28/wix-how-to-run-application-with-parameters-from-custom-action/
有任何想法吗? 谢谢。
经过几次尝试。...当前,当触发CustomAction时,我的msi以运行时错误结束。 (hogehoge.bat是空白文本文件,并且当Publish Event =“ DoAction”标记被注释掉时,不会发生此错误。)
main.wxs
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="HogeHoge" Name="HogeHoge">
<Directory Id="INSTALLDIR" Name="Hoge 1.0">
<Component Id="HogeHogeLibrary" Guid="MY-GUID">
<File Id="test.bat" Name="test.bat" DiskId="1" Source="test.bat" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
</Directory>
<Directory Id="SxSFolder" Name="SxS" />
<Directory Id="SQLServerFolder" Name="SQLServer">
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
<Feature Id="Complete" Title="HogeHoge 1.12.0" Description="Complete Package" Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR">
<Feature Id="MainProgram" Title="Program" Description="Main Program" Level="1">
<ComponentRef Id="HogeHogeLibrary" />
</Feature>
<Component Id="hogehoge" Guid="MY-GUID" Directory="TARGETDIR">
<File Id="hogehoge" DiskId="1" Name="hogehoge.bat" KeyPath="yes" Source="hogehoge.bat" />
</Component>
</Feature>
<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<DialogRef Id="WindowsServerRolesAndFeaturesDlg" />
<DialogRef Id="SQLServerInstallDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg" Order="2">
LicenseAccepted = "1"
</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="Next" Event="NewDialog" Value="SQLServerInstallDlg" Order="2">
LicenseAccepted = "1"
</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="SQLServerInstallDlg">
1
</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="Next" Event="SetTargetPath" Value="[SXS_PATH]" Order="2">1</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[SXS_PATH]" Order="1">1</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Dialog="SQLServerInstallDlg" Control="Back" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="SQLServerInstallDlg" Control="Next" Event="SetTargetPath" Value="[SQLSERVER_INSTANCE_PATH]" Order="2">1</Publish>
<Publish Dialog="SQLServerInstallDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[SQLSERVER_INSTANCE_PATH]" Order="1">1</Publish>
<Publish Dialog="SQLServerInstallDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</UI>
<UIRef Id="WixUI_ErrorProgressText" />
</Product>
main.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!--<CustomAction Id="OnlineSxSInstall" Return="check" Execute="immediate" ExeCommand="install_win2012_online" />-->
<CustomAction Id="OfflineSxSInstall" Property="CMD" Return="check" Execute="immediate" ExeCommand="/c ""[#hogehoge]""" />
<Property Id="ONOFF_PROPERTY" Secure="yes" Value="0" />
<UI>
<Dialog Id="WindowsServerRolesAndFeaturesDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
<Control Id="RdxOnlineOffline" Type="RadioButtonGroup" X="40" Y="63" Width="200" Height="35" Property="ONOFF_PROPERTY" Text="Choose install method:">
<RadioButtonGroup Property="ONOFF_PROPERTY">
<RadioButton Value="0" X="0" Y="0" Width="300" Height="15" Text="local package or online windows update available" />
<RadioButton Value="1" X="0" Y="20" Width="300" Height="15" Text="Require offline install from a media" />
</RadioButtonGroup>
</Control>
<Control Id="SourcePath" Type="Text" X="45" Y="98" Width="200" Height="15" TabSkip="no" Text="Input Sxs path when offline(&U):" />
<Control Type="PathEdit" Id="TxtDir" X="45" Y="110" Width="220" Height="18" Property="SXS_PATH" Indirect="yes">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="ChangeFolder" Type="PushButton" X="265" Y="110" Width="56" Height="18" Text="Browse...">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back(&B)">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next(&N)">
<Publish Event="DoAction" Value="OfflineSxSInstall">1</Publish>
<Publish Event="NewDialog" Value="SQLServerInstallDlg" />
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
<Text>Install Windows IIS role and .NET Framework features</Text>
</Control>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Set IIS role and .NET Framework 3.5 features</Text>
</Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>
有任何想法吗?
正如您在第2节中所确定的那样,几乎可以肯定是问题所在。在UI序列中运行的自定义操作无法以高程运行,因为默认情况下,UI序列未升高。 根据定义,延迟的自定义操作也将在InstallExecuteSequence中运行。 没有右键单击以管理员身份运行MSI。 您将需要一个具有海拔清单的启动程序可执行文件,该清单可执行MSI文件的CreateProcess()型启动(或MsiInstallProduct API调用),以在提升模式下启动UI序列。
在UI阶段更改系统是不正确的做法,因为用户可以取消安装(否则安装可能会失败),然后系统将保持更改状态。 最佳实践是,如果安装失败或被取消,则将系统还原到其原始状态。
尚不清楚您的DISM到底应该完成什么。 可能还有其他方法可以解决此问题-您实际上并未描述要解决的问题,您想知道如何实现建议的解决方案,一个经典的XY问题 。基本问题似乎是您希望运行DISM的任何问题做。
如果安装不需要DISM配置步骤,则它可以在安装后作为应用程序的一部分作为单独的配置步骤运行。 此外,还有一些DISM API调用可以完成任何任务,因此也许您不需要显式运行DISM。 这可能是“开发人员懒惰”的典型案例,他们说“哦,我们将安装该软件来执行DISM任务,这不属于我们的应用程序”。 安装需要它还是应用程序?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.