Wix:无法从Wix CustomAction调用DISM [英] Wix: Cannot call DISM from Wix CustomAction

查看:77
本文介绍了Wix:无法从Wix CustomAction调用DISM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wix 3.10

阅读文章后(在customAction中运行ExeCommand作为Wix安装程序中的管理员模式), 我使用了具有属性Impersonate ="no"的推迟的CustomAction,并使用DISM命令调用了批处理文件.

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 &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版本....

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

首先,我尝试为64位Windows 2012R2测试环境调用正确的CMD.exe和DISM.exe,...但是尽管DISM的绝对路径始终会返回相同的错误,因此更改Path ="[SystemFolder]到"[System64Folder]" ...

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

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

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

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

有什么想法吗?恐怕我必须面对一些大问题,例如DISM API....

Any ideas? I'm afraid that I must face something big thing like the DISM API....

P.S. 遵循@Chris Riccio的建议,我停止使用批处理文件,并且QuietExec可以正常工作,而AddIISComponent命令并不长. (如果使用注释掉命令,LIGHT会警告"LGHT1076:ICE03:字符串溢出(大于列中允许的长度);表:CustomAction,列:Target,键:AddDISMComponent.")

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>  

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

I have currently tried to call multiple QuietExec-DISM commands chopping up the long parameters...

不聪明...

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

推荐答案

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

You can use the built in Wix QuietExec custom action to run the dism command line - this should simplify the installer quite a bit

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

这是完整的示例

这篇关于Wix:无法从Wix CustomAction调用DISM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆