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

Can not enable IIS features in Windows 10 via running a batch file including the command below? Is the DISM command different in Windows 10 ? or Should I include any arguments?

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

The Problem is even if I start the batch under elevated access, it does not start the dism tool with those rights. And it quits.

DISM logs

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
Kubi
  • 2,139
  • 6
  • 35
  • 62

1 Answers1

0

The problem here was because of the elevated priviligas and the x64 version of the DISM tool.

I changed my batch to force for admin rights and then redirect the dism path to native version as below. Answering my own question in case it helps others facing the same issue.

    @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
Kubi
  • 2,139
  • 6
  • 35
  • 62