DismRestoreImageHealth function

Repairs a corrupted image that has been identified as repairable by DismCheckImageHealth.

Syntax

HRESULT WINAPI DismRestoreImageHealth(
  _In_     DismSession            Session,
  _In_opt_ PCWSTR                 *SourcePaths,
  _In_opt_ UINT                   SourcePathCount,
  _In_     BOOL                   LimitAccess,
  _In_opt_ HANDLE                 CancelEvent,
  _In_opt_ DISM_PROGRESS_CALLBACK Progress,
  _In_opt_ PVOID                  UserData
);

Parameters

Session [in]
A valid DismSession. The DismSession must be associated with an image. You can associate a session with an image by using the DismOpenSession.

SourcePaths [in, optional]
Optional. A list of source locations to check for repair files.

SourcePathCount [in, optional]
Optional. The number of source locations specified.

LimitAccess [in]
A Boolean value that indicates whether the DismRestoreImageHealth function should contact Windows Update (WU) as a source location for downloading repair files. Before checking WU, DISM will check for the files in the SourcePaths provided and in any locations specified in the registry by Group Policy. If the files that are required to enable the feature are found in these other specified locations, this flag is ignored.

Value Description
TRUE Do not check WU for repair files.
FALSE Default. Check WU for repair files.

CancelEvent [in, optional]
Optional. You can set a CancelEvent for this function in order to cancel the operation in progress when signaled by the client. If the CancelEvent is received at a stage when the operation cannot be canceled, the operation will continue and return a success code. If the CancelEvent is received and the operation is canceled, the image state is unknown. You should verify the image state before continuing or discard the changes and start again.

Progress [in, optional]
Optional. A pointer to a client-defined DismProgressCallback.

UserData [in, optional]
Optional. User defined custom data.

Return value

Returns S_OK on success.

Remarks

Run DismCheckImageHealth to determine if the image is corrupted and if the image is repairable. If the DismCheckImageHealth returns DismImageRepairable, the DismRestoreImageHealth function can repair the image.

If a repair file is not found in any of the locations specified by the SourcePaths parameter or the location paths in the registry specified by Group Policy, the DismRestoreImageHealth function will contact WU to check for a repair file unless the LimitAccess parameter is set to TRUE.

Example

HRESULT hr = S_OK;
hr = DismRestoreImageHealth(Session, NULL, 0, TRUE, NULL, NULL, NULL);

Requirements

Requirement Description
Supported host platforms DISM API can be used on any operating system supported by the Windows Assessment and Deployment Kit (Windows ADK). For more information, see the Windows ADK Technical Reference.
Supported image platforms Windows 8, Windows Server 2012, Windows 8.1, Windows Server 2012 R2, Windows 10, Windows Server 2016
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Header DismAPI.h
Library DismAPI.lib
DLL DismAPI.dll

See also

DismCheckImageHealth

DismImageHealthState