Wix:无法从Wix CustomAction调用DISM

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wix:无法从Wix CustomAction调用DISM相关的知识,希望对你有一定的参考价值。

Wix 3.10

阅读文章(qazxsw poi)后,我使用了一个带有属性Impersonate =“no”的延迟自定义操作,使用DISM命令调用批处理文件。

Run ExeCommand in customAction as Administrator mode in Wix Installer

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

首先,我试图为64位Windows 2012R2测试环境调用正确的CMD.exe和DISM.exe,但是尽管DISM的绝对路径,将Path =“[SystemFolder]”更改为“”仍会返回相同的错误[System64Folder]” ...

然后我发现了一篇有类似现象的文章( <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> )它告诉我它源于缺乏许可......

目前我试图通过使用schtasks.exe明确地以管理员身份运行来解决问题...(可能是Wix公共参数的登录名和密码....用户输入Wix UI窗口,丑陋....)

configure.bat

https://social.technet.microsoft.com/Forums/ie/en-US/e25c27cf-ca6d-4079-90a1-8201ffc503e5/dism-gives-error-11?forum=w8itprogeneral

有任何想法吗?我担心我必须面对像DISM API这样的大事......

附:按照@Chris Riccio的建议,我停止使用批处理文件,QuietExec工作正常,而AddIISComponent命令不是那么长。 (如果我使用了注释命令,LIGHT警告“LGHT1076:ICE03:字符串溢出(大于列中允许的长度);表:CustomAction,Column:Target,Key(s):AddDISMComponent。”)

setlocal

echo @Starting Installation of IIS Role Services and .NET Framework.... @%DATE%_%TIME%   >> C:	emp	est_configure.txt 2>&1


REM cd C:WindowsSysWOW64
cd >> C:	emp	est_configure.txt 2>&1
echo %1 >> C:	emp	est_configure.txt 2>&1
SET SXS_SOURCE_PATH=%1

DISM.exe /Online /Enable-Feature /FeatureName:NetFx3 /All /Source:%SXS_SOURCE_PATH% >> C:	emp	est_configure.txt 2>&1
if !ERRORLEVEL! neq 0 (
    ECHO interrupting Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME%  >> C:	emp	est_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:	emp	est_configure.txt 2>&1

if !ERRORLEVEL! neq 0 (
    ECHO @interrupting Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME%  >> C:	emp	est_configure.txt 2>&1
    EXIT /B 100
)       



echo @Complete  Installation of IIS Role Services and .NET Framework....@%DATE%_%TIME%   >> C:	emp	est_configure.txt 2>&1

endlocal
exit /B 0

我目前试图调用多个QuietExec-DISM命令来切断长参数...

不聪明....

    <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>  
答案

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

    <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>  

这是一个完整的 <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

以上是关于Wix:无法从Wix CustomAction调用DISM的主要内容,如果未能解决你的问题,请参考以下文章

WiX CustomActionData 在调用的 CustomAction 中为空

wix customaction UAC dtf

以提升用户身份在 wix 中运行 CustomAction

具有提升权限的 WiX CustomAction SCHTASKS“拒绝访问”

Wix Toolset CustomAction 用于确定操作系统是 windows 7/xp 家庭版还是入门版,并显示消息不是

WiX:如何打包 exe 或 dll 以仅在安装期间使用