如何強制安裝已完全刪除且在 Dism /online /Get-Features 中不存在的 Windows 選用功能?

如何強制安裝已完全刪除且在 Dism /online /Get-Features 中不存在的 Windows 選用功能?

原始的 Windows 11 安裝程式 ISO 會修改為在受限資源設定中運作,因此完全刪除了大多數 Windows 元件、套件或功能的痕跡,以最大限度地減少最終安裝的大小。這個修改後的ISO被用來安裝在目前系統上。這樣即使運行也Dism /online /Get-Features不會列出該功能。

安裝原始(未修改)官方完整 Windows 11 ISO 映像:

PS C:\> Dism /Mount-Image /ImageFile:E:\Sources\install.wim /Index:7 /MountDir:C:\test\offline /Readonly

Deployment Image Servicing and Management tool
Version: 10.0.22621.1

Mounting image
[==========================100.0%==========================]
The operation completed successfully.

原始ISO具有以下特點:

PS C:\> Dism /Image:C:\test\offline /Get-FeatureInfo /FeatureName:Microsoft-Windows-Subsystem-Linux

Deployment Image Servicing and Management tool
Version: 10.0.22621.1

Image Version: 10.0.22621.525

Feature Information:

Feature Name : Microsoft-Windows-Subsystem-Linux
Display Name : Windows Subsystem for Linux
Description : Provides services and environments for running native user-mode Linux shells and tools on Windows.
Restart Required : Possible
State : Disabled

Custom Properties:

ServerComponent\Description : Provides services and environments for running native user-mode Linux shells and tools on Windows.
ServerComponent\DisplayName : Windows Subsystem for Linux
ServerComponent\Id : 1033
ServerComponent\Type : Feature
ServerComponent\UniqueName : Microsoft-Windows-Subsystem-Linux
ServerComponent\Deploys\Update\Name : Microsoft-Windows-Subsystem-Linux

The operation completed successfully.

此功能已完成刪除(在修改後的 ISO 安裝程式上),因此在安裝的 Windows 上,此功能無法辨識:

PS C:\> Dism /Online /Get-FeatureInfo /FeatureName:Microsoft-Windows-Subsystem-Linux

Deployment Image Servicing and Management tool
Version: 10.0.22621.1

Image Version: 10.0.22621.1245


Error: 0x800f080c

Feature name Microsoft-Windows-Subsystem-Linux is unknown.
A Windows feature name was not recognized.
Use the /Get-Features option to find the name of the feature in the image and try the command again.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log

由於無法識別該功能,因此無法安裝該功能(儘管存在於 /Source 上):

PS C:\> Dism /Online /Enable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux /Source:C:\test\offline\Windows\WinSxS\ /All /LimitAccess

Deployment Image Servicing and Management tool
Version: 10.0.22621.1

Image Version: 10.0.22621.1245


Error: 0x800f080c

Feature name Microsoft-Windows-Subsystem-Linux is unknown.
A Windows feature name was not recognized.
Use the /Get-Features option to find the name of the feature in the image and try the command again.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log

使用了 DISM,但解決方案不必使用 DISM。此外,如果每個可選功能都存在獨立安裝程序,那麼這將是一個有效的解決方案。現在,如何在不執行完整作業系統安裝的情況下啟用此類功能(和依賴項)?

僅最後一個指令的日誌檔 ( C:\Windows\Logs\Dism\dism.log ):

2023-02-07 02:52:29, Info                  DISM   PID=20420 TID=20424 Scratch directory set to 'C:\Users\Admin\AppData\Local\Temp\'. - CDISMManager::put_ScratchDir
2023-02-07 02:52:29, Info                  DISM   PID=20420 TID=20424 DismCore.dll version: 10.0.22621.1 - CDISMManager::FinalConstruct
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   PID=20420 TID=20424 Successfully loaded the ImageSession at "C:\Windows\system32\Dism" - CDISMManager::LoadLocalImageSession
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   DISM Provider Store: PID=20420 TID=20424 Found and Initialized the DISM Logger. - CDISMProviderStore::Internal_InitializeLogger
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Successfully created the local image session and provider store. - CDISMManager::CreateLocalImageSession
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: 
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: <----- Starting Dism.exe session ----->
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: 
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Host machine information: OS Version=10.0.22621, Running architecture=amd64, Number of processors=2
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Dism.exe version: 10.0.22621.1
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Executing command line: "C:\Windows\system32\Dism.exe" /Online /Enable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux /Source:C:\test\offline\Windows\WinSxS\ /All /LimitAccess
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 physical location path: C:\ - CDISMManager::CreateImageSession
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Event name for current DISM session is Global\{3215538E-EA92-474F-A021-31BC279C7964} - CDISMManager::CheckSessionAndLock
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Create session event 0x248 for current DISM session and event name is Global\{3215538E-EA92-474F-A021-31BC279C7964}  - CDISMManager::CheckSessionAndLock
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Copying DISM from "C:\Windows\System32\Dism" - CDISMManager::CreateImageSessionFromLocation
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 No Sandbox was created, DISM running in-place. - CDISMManager::CreateImageSessionFromLocation
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Successfully loaded the ImageSession at "C:\Windows\System32\Dism" - CDISMManager::LoadRemoteImageSession
2023-02-07 02:52:29, Info                  DISM   DISM Image Session: PID=20448 TID=20468 Instantiating the Provider Store. - CDISMImageSession::get_ProviderStore
2023-02-07 02:52:29, Info                  DISM   DISM OS Provider: PID=20448 TID=20468 Defaulting SystemPath to C:\ - CDISMOSServiceManager::Final_OnConnect
2023-02-07 02:52:29, Info                  DISM   DISM OS Provider: PID=20448 TID=20468 Defaulting Windows folder to C:\Windows - CDISMOSServiceManager::Final_OnConnect
2023-02-07 02:52:29, Info                  DISM   DISM Provider Store: PID=20448 TID=20468 Attempting to initialize the logger from the Image Session. - CDISMProviderStore::Final_OnConnect
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   DISM Provider Store: PID=20448 TID=20468 Found and Initialized the DISM Logger. - CDISMProviderStore::Internal_InitializeLogger
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   Initialized Panther logging at C:\Windows\Logs\DISM\dism.log
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Image session successfully loaded from location: C:\Windows\System32\Dism - CDISMManager::CreateImageSession
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Target image information: OS Version=10.0.22621.1245, Image architecture=amd64
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Image session version: 10.0.22621.1
2023-02-07 02:52:29, Info                  DISM   DISM Transmog Provider: PID=20448 TID=20468 Current image session is [ONLINE] - CTransmogManager::GetMode
2023-02-07 02:52:29, Info                  DISM   DISM Transmog Provider: PID=20448 TID=20468 Audit Mode: [No] - CTransmogManager::Initialize
2023-02-07 02:52:29, Info                  DISM   DISM Transmog Provider: PID=20448 TID=20468 GetProductType: ProductType = [WinNT] - CTransmogManager::GetProductType
2023-02-07 02:52:29, Info                  DISM   DISM Transmog Provider: PID=20448 TID=20468 Product Type: [WinNT] - CTransmogManager::Initialize
2023-02-07 02:52:29, Info                  DISM   DISM Transmog Provider: PID=20448 TID=20468 Product Type ServerNT : [No] - CTransmogManager::Initialize
2023-02-07 02:52:29, Info                  CSI    00000001 Shim considered [l:126]'\??\C:\Windows\Servicing\amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.22621.1245_none_e95e4cae42cdfd26\wcp.dll' : got STATUS_OBJECT_PATH_NOT_FOUND
2023-02-07 02:52:29, Info                  CSI    00000002 Shim considered [l:123]'\??\C:\Windows\WinSxS\amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.22621.1245_none_e95e4cae42cdfd26\wcp.dll' : got STATUS_SUCCESS
2023-02-07 02:52:29, Info                  DISM   DISM Driver Manager: PID=20448 TID=20468 Further logs for driver related operations can be found in the target operating system at %WINDIR%\inf\setupapi.offline.log - CDriverManager::Initialize
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Finished initializing the CbsConUI Handler. - CCbsConUIHandler::Initialize
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 CBS is being initialized for online use. More information about CBS actions can be located at: %windir%\logs\CBS\CBS.log - CDISMPackageManager::Initialize
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Loaded servicing stack for online use. - CDISMPackageManager::CreateCbsSession
2023-02-07 02:52:29, Info                  CSI    00000001 Shim considered [l:126]'\??\C:\Windows\Servicing\amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.22621.1245_none_e95e4cae42cdfd26\wcp.dll' : got STATUS_OBJECT_PATH_NOT_FOUND
2023-02-07 02:52:29, Info                  CSI    00000002 Shim considered [l:123]'\??\C:\Windows\WinSxS\amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.22621.1245_none_e95e4cae42cdfd26\wcp.dll' : got STATUS_SUCCESS
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Processing the top level command token(enable-feature). - CPackageManagerCLIHandler::Private_ValidateCmdLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Attempting to route to appropriate command handler. - CPackageManagerCLIHandler::ExecuteCmdLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Routing the command... - CPackageManagerCLIHandler::ExecuteCmdLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Encountered the option "featurename" with value "Microsoft-Windows-Subsystem-Linux" - CPackageManagerCLIHandler::Private_GetPackagesFromCommandLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Encountered an unknown option "featurename" with value "Microsoft-Windows-Subsystem-Linux" - CPackageManagerCLIHandler::Private_GetPackagesFromCommandLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Encountered the option "source" with value "C:\test\offline\Windows\WinSxS\" - CPackageManagerCLIHandler::Private_GetPackagesFromCommandLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Encountered an unknown option "source" with value "C:\test\offline\Windows\WinSxS\" - CPackageManagerCLIHandler::Private_GetPackagesFromCommandLine
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 TID=20468 Failed to get the Update through CBS. - CDISMPackage::Internal_OpenFeature(hr:0x800f080c)
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 TID=20468 Failed to get the underlying CBS Feature - CDISMPackage::OpenFeature(hr:0x800f080c)
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 Feature name Microsoft-Windows-Subsystem-Linux is unknown. - CPackageManagerCLIHandler::Private_GetFeaturesFromCommandLine(hr:0x800f080c)
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 TID=20468 Unknown features were specified on the command-line. - CPackageManagerCLIHandler::Private_GetFeaturesFromCommandLine(hr:0x800f080c)
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 TID=20468 Failed to get the Feature List from the command line. - CPackageManagerCLIHandler::Private_ProcessFeatureChange(hr:0x800f080c)
2023-02-07 02:52:29, Error                 DISM   DISM Package Manager: PID=20448 TID=20468 Failed while processing command enable-feature. - CPackageManagerCLIHandler::ExecuteCmdLine(hr:0x800f080c)
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Further logs for online package and feature related operations can be found at %WINDIR%\logs\CBS\cbs.log - CPackageManagerCLIHandler::ExecuteCmdLine
2023-02-07 02:52:29, Info                  DISM   DISM Package Manager: PID=20448 TID=20468 Finalizing CBS core. - CDISMPackageManager::Finalize
2023-02-07 02:52:29, Info                  DISM   DISM Manager: PID=20420 TID=20424 Closing session event handle 0x248 - CDISMManager::CleanupImageSessionEntry
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: Image session has been closed. Reboot required=no.
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: 
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: <----- Ending Dism.exe session ----->
2023-02-07 02:52:29, Info                  DISM   DISM.EXE: 

相關內容