平台:(开发)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命令(可能是管理员帐户),我必须使用某些参数选择某种类型(50?) 在Wix Custom Action元素标签中,对吗? (我想我无法明确选择一种msi自定义动作......)
CustomAction Element
http://wixtoolset.org/documentation/manual/v3/xsd/wix/customaction.html
2)我想在按下“下一步”按钮后使用CustomAction执行:“立即”,但我担心立即自定义操作无法以提升状态调用它(可能DISM命令无法在没有管理员的情况下工作特权...)我会尝试并得到错误,但请教我如果我应该改为执行:“延期”,然后我会筋疲力尽。 (我认为右键单击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>
有什么想法吗?
答案 0 :(得分:1)
问题几乎可以肯定,正如您在第2部分中所确定的那样。在UI序列中运行的自定义操作无法通过高程运行,因为默认情况下UI顺序不会提升。根据定义,延迟的自定义操作也会在InstallExecuteSequence中运行。没有右键单击以管理员身份运行MSI。您需要一个具有提升清单的启动程序可执行文件,该提升清单执行CreateProcess() - 类型启动MSI文件(或MsiInstallProduct API调用)以在提升模式下启动UI序列。
在UI阶段更改系统是不好的做法,因为用户可以取消安装(或者可能失败),然后系统将处于更改状态。如果安装失败或取消,最佳做法是将系统恢复到其原始状态。
目前还不清楚您的DISM究竟应该完成什么。可能还有其他方法可以解决这个问题 - 你实际上并没有描述你想要解决的问题,你想知道如何实现你提出的解决方案,经典XY problem基本问题似乎是你想要的任何你想要的DISM运行。
如果安装不需要DISM配置步骤,则可以在安装后作为应用程序的一部分单独配置步骤运行。此外,还有DISM API调用可以完成任务,因此您可能不需要显式运行DISM。这可能是开发人员懒惰的典型案例&#34;在那里他们说&#34;哦,我们得到安装来做DISM的东西,这不属于我们的应用程序&#34;。安装是否需要它或应用程序?