问题描述
环境:Windows 7(x64),WiX工具集3.10
Environment: Windows 7(x64), WiX toolset 3.10
我为WixUI_Mondo序列添加了一个窗口,以创建用户可以使用的窗口安装IIS角色和.NET Framework 3.5功能...即使环境需要包含SxS软件包的OS介质。 (我知道不建议使用VbScriptCall,但是BrowseDlg在我的环境中不能正常工作......在这个阶段可能无法使用.NET代码。):
I made an additional window to a sequence of "WixUI_Mondo", to make the window which an user can install IIS role and .NET Framework 3.5 features...even if an environment requires a OS media containing SxS package. (I know VbScriptCall is not recommended, but BrowseDlg doesn't work well in my environment...and .NET code might not be available in this phase.):
1)我下面的代码可以调用CustomAction并打开BrowseForFolder,但是它的返回值不与SXS_PATH属性或SourcePathEdit文本框同步,有什么问题?
1) My code below can call CustomAction and open BrowseForFolder, but its return value doesn't synchronize with SXS_PATH property or SourcePathEdit textbox, what is wrong?
片段如下:
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<CustomAction Id="FolderExplorer" BinaryKey="FolderExplorer.vb" Impersonate="yes" Return="check" Execute="immediate" VBScriptCall="GetSxsPath" />
<Binary Id="FolderExplorer.vb" SourceFile="OpenVbScriptFolderExplorer.vbs"/>
<Property Id="ONOFF_PROPERTY" Secure="yes" Value="0" />
<Property Id="SXS_PATH" Value="C:\" />
<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 Id="SourcePathEdit" Type="Edit"
X="45" Y="110" Width="220" Height="18"
Property="SXS_PATH" Text="{80}">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="SourcePathButton" Type="PushButton"
X="265" Y="110" Width="56" Height="18"
Default="yes" Text="Refer..">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
<Publish Event="DoAction" Value="FolderExplorer">1</Publish>
</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="次へ(&N)">
<!--<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>-->
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</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>
VBScript如下:
VBScript is below:
Option Explicit
public sub GetSxsPath()
Dim objShell
Dim objFolder
Dim objFolderItem
Dim strPath
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Choose SxS Folder for IIS role and .NET features", NO_OPTIONS)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
MsgBox(strPath)
if Err.Number = 0 then
Session.Property("SXS_PATH") = strPath
end if
exit sub
end sub
2)如果1)成功,我想使用另一个自定义操作来调用DOS命令DISM,并设置SXS_PATH。有什么想法吗?
2)If 1) is successful, I want to use another custom action to call DOS command DISM, with setting SXS_PATH. Any ideas?
@echo off
SET SXS_PATH=D:\sources\sxs ←here insert the path 1)SourcePathEdit value...
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /Source:%SXS_PATH%
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security /FeatureName:IIS-HttpLogging /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-ManagementConsole /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-Metabase /FeatureName:IIS-WebServer /FeatureName:IIS-Performance /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-StaticContent /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASPNET /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /all /Source:%SXS_PATH%
推荐答案
这是自我回复:
这不是CustomAction的正确答案,但至少我找到了解决方案我想:将Explorer选择值设置为WiX编辑框。
(阅读文章和GitHub示例)
It is not a right answer to "CustomAction", but at least I find a solution what I want: to set Explorer selection value to a WiX editbox. (reading an article Use WiX browser dialog to set edit box value and GitHub sample https://github.com/misohena/simple_wix_template)
如果属性引用的目录标记集(SxSFolder条目(D))不存在,我的安装程序似乎会出现错误代码2343(值(B)和属性(A)(C))
It seems that my installer groans Error Code 2343 if a directory tag set ("SxSFolder" entry (D) ) doesn't exist which is referred by the property (value (B) and property (A)(C))
我还在研究CustomAction来调用DOS DISM命令:
谢谢:
I'm still studying CustomAction to call DOS DISM command:Thank you:
下面是一个很长但有效的样本:
Below is a long but working sample:
Main.wxs
Main.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Name="FugaFuga 1.12.0" Id="MY-UID" UpgradeCode="MY-UID" Language="1041" Codepage="932" Version="1.12.0" Manufacturer="HogeHoge">
<Package Id="*" Keywords="Installer" Description="FugaFuga 1.12.0 Installer" Comments="FugaFuga is trademark of HogeHoge Inc." Manufacturer="HogeHoge" InstallerVersion="100" Languages="1041" Compressed="yes" SummaryCodepage="932" />
<Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM 1" />
<Property Id="DiskPrompt" Value="HogeHoge FugaFuga 1.12.0 Installer [1]" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Property Id="SXS_PATH" Secure="yes" Value="SxSFolder" /><!--(C)-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="FugaFuga" Name="FugaFuga">
<Directory Id="INSTALLDIR" Name="Hoge 1.0">
<Component Id="FugaFugaLibrary" Guid="MY-UID">
<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" /><!--(D)-->
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
<Feature Id="Complete" Title="FugaFuga 1.12.0" Description="Complete Package" Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR">
<Feature Id="MainProgram" Title="Program" Description="Main Program" Level="1">
<ComponentRef Id="FugaFugaLibrary" />
</Feature>
</Feature>
<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<DialogRef Id="WindowsServerRolesAndFeaturesDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg" Order="2">
LicenseAccepted = "1"
</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg">
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><!--(B)-->
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</UI>
<UIRef Id="WixUI_ErrorProgressText" />
</Product>
</Wix>
WindowsServerRolesAndFeaturesDlg.wxs
WindowsServerRolesAndFeaturesDlg.wxs
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<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)(&U):" />
<Control Type="PathEdit" Id="TxtDir" X="45" Y="110" Width="220" Height="18" Property="SXS_PATH" Indirect="yes"><!--(A)-->
<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="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>-->
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</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>
这篇关于WiX无法将会话值输入到文本框(使用CustomAction)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!