【问题标题】:Wix Can't Enable IIS in Windows 10 via DISM commandWix 无法通过 DISM 命令在 Windows 10 中启用 IIS
【发布时间】:2015-10-20 19:17:05
【问题描述】:
<CustomAction Id="ENABLEIIS" Property="CMD" Impersonate="yes" Execute="immediate" ExeCommand='/k fixiis.lnk' Return="ignore"/>

            <Property Id="CMD">
 <DirectorySearch Id="SysDir" Path="[SystemFolder]" Depth="1">
   <FileSearch Id="CmdExe" Name="cmd.exe"  />
 </DirectorySearch>
</Property>

无法通过运行包含以下命令的批处理文件在 Windows 10 中启用 IIS 功能? Windows 10 中的 DISM 命令是否不同?或者我应该包含任何参数吗?

START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-NetFxExtensibility45

问题是即使我在提升的访问权限下启动批处理,它也不会以这些权限启动 dism 工具。然后它就退出了。

DISM 日志

2015-10-20 22:10:57, Info                  DISM   PID=10832 TID=13580 Scratch directory set to 'C:\Users\KUBILA~1\AppData\Local\Temp\'. - CDISMManager::put_ScratchDir
2015-10-20 22:10:57, Info                  DISM   PID=10832 TID=13580 DismCore.dll version: 10.0.10240.16384 - CDISMManager::FinalConstruct
2015-10-20 22:10:57, Info                  DISM   PID=10832 TID=13580 Successfully loaded the ImageSession at "C:\WINDOWS\System32\Dism" - CDISMManager::LoadLocalImageSession
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Found and Initialized the DISM Logger. - CDISMProviderStore::Internal_InitializeLogger
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Failed to get and initialize the PE Provider.  Continuing by assuming that it is not a WinPE image. - CDISMProviderStore::Final_OnConnect
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Finished initializing the Provider Map. - CDISMProviderStore::Final_OnConnect
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Getting Provider DISMLogger - CDISMProviderStore::GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Provider has previously been initialized.  Returning the existing instance. - CDISMProviderStore::Internal_GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Getting Provider DISMLogger - CDISMProviderStore::GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Provider has previously been initialized.  Returning the existing instance. - CDISMProviderStore::Internal_GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Manager: PID=10832 TID=13580 Successfully created the local image session and provider store. - CDISMManager::CreateLocalImageSession
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Getting Provider DISMLogger - CDISMProviderStore::GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Provider has previously been initialized.  Returning the existing instance. - CDISMProviderStore::Internal_GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: 
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: <----- Starting Dism.exe session ----->
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: 
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: Host machine information: OS Version=10.0.10240, Running architecture=x86, Number of processors=8
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: Dism.exe version: 10.0.10240.16384
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: Executing command line: DISM  /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-NetFxExtensibility45
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Getting Provider FolderManager - CDISMProviderStore::GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Provider has not previously been encountered.  Attempting to initialize the provider. - CDISMProviderStore::Internal_GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Loading Provider from location C:\WINDOWS\System32\Dism\FolderProvider.dll - CDISMProviderStore::Internal_GetProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Connecting to the provider located at C:\WINDOWS\System32\Dism\FolderProvider.dll. - CDISMProviderStore::Internal_LoadProvider
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: Image session has been closed. Reboot required=no.
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: 
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: <----- Ending Dism.exe session ----->
2015-10-20 22:10:57, Info                  DISM   DISM.EXE: 
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Found the OSServices.  Waiting to finalize it until all other providers are unloaded. - CDISMProviderStore::Final_OnDisconnect
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Disconnecting Provider: FolderManager - CDISMProviderStore::Internal_DisconnectProvider
2015-10-20 22:10:57, Info                  DISM   DISM Provider Store: PID=10832 TID=13580 Releasing the local reference to DISMLogger.  Stop logging. - CDISMProviderStore::Internal_DisconnectProvider

【问题讨论】:

    标签: iis wix dism


    【解决方案1】:

    这里的问题是因为提升的权限和 DISM 工具的 x64 版本。

    我更改了我的批处理以强制获得管理员权限,然后将 dism 路径重定向到本机版本,如下所示。回答我自己的问题,以防其他人遇到同样的问题。

        @echo off
    
    :checkPrivileges
    NET FILE 1>NUL 2>NUL
    if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
    
    :getPrivileges
    if '%1'=='ELEV' (echo ELEV & shift & goto gotPrivileges)
    
    setlocal DisableDelayedExpansion
    set "batchPath=%~0"
    setlocal EnableDelayedExpansion
    ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
    ECHO args = "ELEV " >> "%temp%\OEgetPrivileges.vbs"
    ECHO For Each strArg in WScript.Arguments >> "%temp%\OEgetPrivileges.vbs"
    ECHO args = args ^& strArg ^& " "  >> "%temp%\OEgetPrivileges.vbs"
    ECHO Next >> "%temp%\OEgetPrivileges.vbs"
    ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
    "%SystemRoot%\System32\WScript.exe" "%temp%\OEgetPrivileges.vbs" %*
    exit /B
    
    :gotPrivileges
    if '%1'=='ELEV' shift
    setlocal & pushd .
    cd /d %~dp0
    
    if EXIST %WINDIR%\system32\dism.exe ( 
      set DISM=%WINDIR%\system32\dism.exe 
    ) 
    if EXIST %WINDIR%\SysNative\dism.exe ( 
      set DISM=%WINDIR%\SysNative\dism.exe 
    ) 
    
    %DISM% /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-NetFxExtensibility45
    

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 1970-01-01
      • 2018-07-27
      • 1970-01-01
      • 2016-10-10
      • 1970-01-01
      • 2016-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多