Wix 3.10
After reading the article (Run ExeCommand in customAction as Administrator mode in Wix Installer), I have used a deferred CustomAction with attribute Impersonate="no", calling a batch file with DISM command.
<Property Id="CMD">
<DirectorySearch Id="CmdFolder" Path="[SystemFolder]" Depth="1">
<FileSearch Id="CmdExe" Name="cmd.exe" />
</DirectorySearch>
</Property>
<Property Id="SXSPATH" Secure="yes" Value="SXSFOLDER" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="SXSFOLDER" />
</Directory>
<CustomAction Id="SetCustomActionData" Return="check" Property="OfflineSxSInstall" Value="[SXSFOLDER]" />
<CustomAction Id="OfflineSxSInstall" Property="CMD" Execute="deferred" Return="check" Impersonate="no" ExeCommand="/c ""[#file_configure.bat]" "[SXSFOLDER]""" />
<InstallExecuteSequence>
<Custom Action="OfflineSxSInstall" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>
Sadly, always DISM returns error 11 "You cannot service a running 64-bit operating system with a 32-bit version of DISM. Please use the version of DISM that corresponds to your computer's architecture"....
Firstly, I have tried to call proper CMD.exe and DISM.exe for the 64bit Windows 2012R2 test environment, ..... but always returns same error despite the absolute path of DISM, changing Path="[SystemFolder]" to "[System64Folder]"...
Then I found an article with Similar phenomenon (https://social.technet.microsoft.com/Forums/ie/en-US/e25c27cf-ca6d-4079-90a1-8201ffc503e5/dism-gives-error-11?forum=w8itprogeneral) It tells me that it derived from lack of permission...
Currently I have tried to solve the problem by using schtasks.exe clearly running as Administrator...(Probably with login and password by Wix public parameter....user input with Wix UI window, ugly....)
configure.bat
setlocal
echo @Starting Installation of IIS Role Services and .NET Framework.... @%DATE%_%TIME% >> C:\temp\test_configure.txt 2>&1
REM cd C:\Windows\SysWOW64
cd >> C:\temp\test_configure.txt 2>&1
echo %1 >> C:\temp\test_configure.txt 2>&1
SET SXS_SOURCE_PATH=%1
DISM.exe /Online /Enable-Feature /FeatureName:NetFx3 /All /Source:%SXS_SOURCE_PATH% >> C:\temp\test_configure.txt 2>&1
if !ERRORLEVEL! neq 0 (
ECHO interrupting Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME% >> C:\temp\test_configure.txt 2>&1
EXIT /B 100
)
DISM.exe /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_SOURCE_PATH% >> C:\temp\test_configure.txt 2>&1
if !ERRORLEVEL! neq 0 (
ECHO @interrupting Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME% >> C:\temp\test_configure.txt 2>&1
EXIT /B 100
)
echo @Complete Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME% >> C:\temp\test_configure.txt 2>&1
endlocal
exit /B 0
Any ideas? I'm afraid that I must face something big thing like the DISM API....
P.S. Following kind @Chris Riccio's advice, I stopped using batch file, and QuietExec works fine, while the AddIISComponent command is not so long. (If I used the comment out command, LIGHT warned "LGHT1076 : ICE03: String overflow (greater than length permitted in column); Table: CustomAction, Column: Target, Key(s): AddDISMComponent." )
<CustomAction Id="SetCustomActionData" Return="check" Property="AddDISMComponent" Value="[SXSFOLDER]" />
<!--<CustomAction Id='AddDISMComponent' Property='DISMComponent' Value='"[System64Folder]dism.exe" /norestart /quiet /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 /FeatureName:NetFx3 /all /Source:[SXSFOLDER]' Execute='immediate'/>-->
<CustomAction Id='AddDISMComponent' Property='DISMComponent' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-WebServerRole /FeatureName:NetFx3 /all /Source:[SXSFOLDER]' Execute='immediate'/>
<CustomAction Id="DISMComponent" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="ignore" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="AddDISMComponent" After="CostFinalize" />
<Custom Action="DISMComponent" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom>
</InstallExecuteSequence>
I have currently tried to call multiple QuietExec-DISM commands chopping up the long parameters...
Not smart....
<CustomAction Id='AddDISMComponent1' Property='DISMComponent1' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-WebServerRole /Source:[SXSFOLDER]' Execute='immediate'/>
<CustomAction Id="DISMComponent1" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id='AddDISMComponent2' Property='DISMComponent2' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-RequestFiltering /Source:[SXSFOLDER]' Execute='immediate'/>
<CustomAction Id="DISMComponent2" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="AddDISMComponent1" After="CostFinalize" />
<Custom Action="AddDISMComponent2" After="AddDISMComponent1" />
<Custom Action="DISMComponent1" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom>
<Custom Action="DISMComponent2" After="DISMComponent1"><![CDATA[(NOT Installed)]]></Custom>
</InstallExecuteSequence>