首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wix:无法从Wix CustomAction调用DISM

Wix:无法从Wix CustomAction调用DISM
EN

Stack Overflow用户
提问于 2018-02-16 18:22:40
回答 2查看 702关注 0票数 1

Wix 3.10

读完这篇文章(Run ExeCommand in customAction as Administrator mode in Wix Installer)后,我使用了一个延迟的CustomAction,属性为Impersonate="no",用DISM命令调用一个批处理文件。

代码语言:javascript
复制
    <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 &quot;&quot;[#file_configure.bat]&quot; &quot;[SXSFOLDER]&quot;&quot;" />

    <InstallExecuteSequence>
        <Custom Action="OfflineSxSInstall" After="InstallFiles">NOT Installed</Custom>
    </InstallExecuteSequence>  

遗憾的是,DISM总是返回错误11“您无法使用32位版本的DISM为正在运行的64位操作系统提供服务。请使用与您的计算机体系结构相对应的DISM版本”……

首先,我尝试为64位Windows2012R2测试环境调用合适的CMD.exe和DISM.exe,.....但总是返回相同的错误,尽管有DISM的绝对路径,将Path="SystemFolder“更改为"System64Folder"...

然后我发现了一篇类似现象的文章(https://social.technet.microsoft.com/Forums/ie/en-US/e25c27cf-ca6d-4079-90a1-8201ffc503e5/dism-gives-error-11?forum=w8itprogeneral),它告诉我它源于缺乏许可……

目前,我试图通过使用schtasks.exe来解决这个问题。)

configure.bat

代码语言:javascript
复制
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

有什么想法吗?我担心我必须面对像DISM API这样的大问题……

附注:在kind @Chris Riccio的建议下,我停止使用批处理文件,虽然AddIISComponent命令不是很长,但QuietExec工作得很好。(如果我使用了comment out命令,LIGHT警告"LGHT1076 : ICE03: String overflow (大于列中允许的长度);表: CustomAction,列:目标,键(S):AddDISMComponent“。)

代码语言:javascript
复制
    <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>  

我目前已经尝试调用多个QuietExec-DISM命令来分解长参数...

不聪明..。

代码语言:javascript
复制
    <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>  
EN

回答 2

Stack Overflow用户

发布于 2018-02-20 07:31:08

您可以使用内置的Wix QuietExec自定义操作来运行dism命令行这应该会大大简化安装程序

代码语言:javascript
复制
    <CustomAction Id='AddIISComponent' Property='IISComponent' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /featurename:IIS-WebServerRole /all' Execute='immediate'/>
    <CustomAction Id="IISComponent" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="ignore" Impersonate="no" />
    <InstallExecuteSequence>
        <Custom Action="AddIISComponent" After="CostFinalize" />
        <Custom Action="IISComponent" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom> 
    </InstallExecuteSequence>

这是一个完整的sample

票数 2
EN

Stack Overflow用户

发布于 2018-03-01 14:38:48

并不聪明,因为我的expected....but工作。

代码语言:javascript
复制
    <CustomAction Id='AddDISMComponent1' Property='DISMComponent1' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-WebServerRole /all /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 /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent2" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent3' Property='DISMComponent3' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-HttpLogging /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent3" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent4' Property='DISMComponent4' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-HealthAndDiagnostics /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent4" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent5' Property='DISMComponent5' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-WebServerManagementTools /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent5" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent6' Property='DISMComponent6' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-ManagementConsole /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent6" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent7' Property='DISMComponent7' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-IIS6ManagementCompatibility /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent7" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent8' Property='DISMComponent8' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-Metabase /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent8" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent9' Property='DISMComponent9' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-WebServer /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent9" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent10' Property='DISMComponent10' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-Performance /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent10" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent11' Property='DISMComponent11' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-HttpCompressionStatic /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent11" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent12' Property='DISMComponent12' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-CommonHttpFeatures /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent12" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent13' Property='DISMComponent13' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-StaticContent /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent13" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent14' Property='DISMComponent14' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-DefaultDocument /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent14" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent15' Property='DISMComponent15' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-DirectoryBrowsing /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent15" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent16' Property='DISMComponent16' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-HttpErrors /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent16" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent17' Property='DISMComponent17' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-ApplicationDevelopment /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent17" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent18' Property='DISMComponent18' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-ASPNET /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent18" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent19' Property='DISMComponent19' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-NetFxExtensibility /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent19" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent20' Property='DISMComponent20' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-ISAPIExtensions /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent20" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent21' Property='DISMComponent21' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:IIS-ISAPIFilter /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent21" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <CustomAction Id='AddDISMComponent22' Property='DISMComponent22' Value='"[System64Folder]dism.exe" /norestart /quiet /online /enable-feature /FeatureName:NetFx3 /all /Source:[SXSFOLDER]' Execute='immediate'/>
    <CustomAction Id="DISMComponent22" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check" Impersonate="no" />

    <InstallExecuteSequence>
      <Custom Action="AddDISMComponent1" After="CostFinalize" />
      <Custom Action="AddDISMComponent2" After="AddDISMComponent1" />
      <Custom Action="AddDISMComponent3" After="AddDISMComponent2" />
      <Custom Action="AddDISMComponent4" After="AddDISMComponent3" />
      <Custom Action="AddDISMComponent5" After="AddDISMComponent4" />
      <Custom Action="AddDISMComponent6" After="AddDISMComponent5" />
      <Custom Action="AddDISMComponent7" After="AddDISMComponent6" />
      <Custom Action="AddDISMComponent8" After="AddDISMComponent7" />
      <Custom Action="AddDISMComponent9" After="AddDISMComponent8" />
      <Custom Action="AddDISMComponent10" After="AddDISMComponent9" />
      <Custom Action="AddDISMComponent11" After="AddDISMComponent10" />
      <Custom Action="AddDISMComponent12" After="AddDISMComponent11" />
      <Custom Action="AddDISMComponent13" After="AddDISMComponent12" />
      <Custom Action="AddDISMComponent14" After="AddDISMComponent13" />
      <Custom Action="AddDISMComponent15" After="AddDISMComponent14" />
      <Custom Action="AddDISMComponent16" After="AddDISMComponent15" />
      <Custom Action="AddDISMComponent17" After="AddDISMComponent16" />
      <Custom Action="AddDISMComponent18" After="AddDISMComponent17" />
      <Custom Action="AddDISMComponent19" After="AddDISMComponent18" />
      <Custom Action="AddDISMComponent20" After="AddDISMComponent19" />
      <Custom Action="AddDISMComponent21" After="AddDISMComponent20" />
      <Custom Action="AddDISMComponent22" After="AddDISMComponent21" />

      <Custom Action="DISMComponent1" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent2" After="DISMComponent1"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent3" After="DISMComponent2"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent4" After="DISMComponent3"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent5" After="DISMComponent4"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent6" After="DISMComponent5"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent7" After="DISMComponent6"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent8" After="DISMComponent7"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent9" After="DISMComponent8"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent10" After="DISMComponent9"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent11" After="DISMComponent10"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent12" After="DISMComponent11"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent13" After="DISMComponent12"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent14" After="DISMComponent13"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent15" After="DISMComponent14"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent16" After="DISMComponent15"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent17" After="DISMComponent16"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent18" After="DISMComponent17"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent19" After="DISMComponent18"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent20" After="DISMComponent19"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent21" After="DISMComponent20"><![CDATA[(NOT Installed)]]></Custom> 
      <Custom Action="DISMComponent22" After="DISMComponent21"><![CDATA[(NOT Installed)]]></Custom> 

    </InstallExecuteSequence>  
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48824644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档