#include-once #include #include "DismConstants.au3" #include "Misc.au3" #include "_DLLStructDisplay.au3" #include ; #INDEX# ======================================================================================================================= ; Title..........: Dismapi v1 (1/03/2013) ; AutoIt Version.: 3.3.8.1 ; Description....: Functions for creating and manipulating WIM images. ; Author(s)......: André Cut ; Dll............: dismapi.dll ; =============================================================================================================================== ; #HISTORY# ====================================================================================================================== ; 24.08.2014 - Using new AutoIT Version: v3.3.13.9 BETA ; 10.09.2014 - Dismapi remastered. Version v1.1 ; 13.03.2015 - Return SetError on DLLCall error ; =============================================================================================================================== ; #TODO'S# ====================================================================================================================== ; GetImageInfo -> If @OSVersion <> "WIN_10" Or @OSVersion <> "WIN_2016" Then -> so geht das nicht, man muss prüfen, ob das wim file win10 oder win7 ist ; =============================================================================================================================== ; #TROUBLESHOOTING# ============================================================================================================= ; 1. When DLLCall not returns Array, you are using the wrong version of dismapi.dll (32/64-Bit) ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $ghdismapi = "C:\Windows\System32\DismApi.dll" ;~ Global $DISM_ERROR_TYPE = 1 ; 0 = Return Error Message Text, 1 = Return Error Code Global $DISM_LOG_PATH = @TempDir & "\DISMlog.log" ; default path to log file ; =============================================================================================================================== ; #CONSTANTS# =================================================================================================================== ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _DISM_AddDriver ; _DISM_AddPackage ; _DISM_ApplyUnattend ;~ ; _DISM_CheckImageHealth ; requires Windows 8 ; _DISM_CleanupMountpoints ; _DISM_CloseSession ; _DISM_CommitImage ; _DISM_Delete ; _DISM_DisableFeature ; _DISM_EnableFeature ; _DISM_GetDriverInfo ; _DISM_GetDrivers ; _DISM_GetFeatureInfo ; _DISM_GetFeatureParent ; _DISM_GetFeatures ; _DISM_GetImageInfo ; _DISM_GetLastErrorMessage ; _DISM_GetMountedImageInfo ; _DISM_GetPackageInfo ; _DISM_GetPackages ; _DISM_Initialize ; _DISM_MountImage ; _DISM_OpenSession ; _DISM_RemountImage ; _DISM_RemoveDriver ; _DISM_RemovePackage ;~ ; _DISM_RestoreImageHealth ; requires Windows 8 ; _DISM_Shutdown ; _DISM_UnmountImage ; =============================================================================================================================== ; #CURRENT SUB# ================================================================================================================= ; _DISM_GetErrorMesageText ; _DISM_GetDriverSignature ; _DISM_GetFullyOfflineInstallableType ; _DISM_GetImageBootable ; _DISM_GetImageType ; _DISM_GetMountMode ; _DISM_GetMountStatus ; _DISM_GetPackageFeatureState ; _DISM_GetReleaseType ; _DISM_GetRestartType ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_AddDriver ; Description ...: Adds a third party driver (.inf) to an offline Windows® image. ; Syntax.........: _DISM_AddDriver($iSession, $sDriverPath, $bForceUnsigned = True) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sDriverPath - A relative or absolute path to the driver .inf file. ; $bForceUnsigned - A Boolean value that specifies whether to accept unsigned drivers to an x64-based image. Unsigned drivers will automatically be added to an x86-based image. ; | True - Add unsigned drivers to an x64-based image. ; | False - Do not add unsigned drivers to an x64-based image. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: This function is only supported for offline images. ; ; Removing a boot-critical driver can make the offline Windows image unbootable. ; Related........: _DISM_GetDriverInfo, _DISM_GetDrivers, _DISM_RemoveDriver ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824764.aspx ; Example .......; In this example, the driver being added is located on the technician computer in the folder C:\drivers\. ; The driver has the filename usb.inf on the technician computer, but is renamed to "OEM1.inf" or "OEM2.inf" in the target image. ; The numbering of the OEMx.inf files is dependent on the number of drivers added. ; The new name, for example OEM1.inf, is returned in the DismDriverPackage Structure when you call the DismGetDrivers Function. ; You should use the new name, OEM1.inf, to specify the DriverPath when you use the DismGetDriverInfo Function. ; ; HRESULT hr = S_OK; ; hr = DismAddDriver(Session, L"C:\\Drivers\\usb.inf", FALSE); ; ; =============================================================================================================================== Func _DISM_AddDriver($iSession, $sDriverPath, $bForceUnsigned = False) Local $aResult = DllCall($ghdismapi, "LONG", "DismAddDriver", _ "PTR", $iSession, _ "WSTR", $sDriverPath, _ "BOOL", $bForceUnsigned _ ) If @error Then Return SetError(@error, 0, "DismAddDriver") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_AddDriver ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_AddPackage ; Description ...: Adds a single .cab or .msu file to a Windows® image. ; Syntax.........: _DISM_AddPackage($iSession, $sPackagePath, $bIgnoreCheck = False, $bPreventPending = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sPackagePath - A relative or absolute path to the .cab or .msu file being added, a folder with one or more packages, or a folder containing the expanded files of a single .cab file. ; $bIgnoreCheck - A Boolean value to specify whether to ignore the internal applicability checks that are done when a package is added. ; | True - Ignore the internal applicability checks. ; | False - Do not ignore the internal applicability checks. ; $bPreventPending - A Boolean value to specify whether to add a package if it has pending online actions. ; | True - Prevent the installation of a package that has pending online actions. ; | False - Allow the installation of a package that has pending online actions. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED (1). ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: Only .cab files can be added to an online image. Either .cab or .msu files can be added to an offline image. ; This function will return a special error code if the package is not applicable. You can use the DismGetPackageInfo Function to determine if a package is applicable to the target image. ; Related........: _DISM_AddDriver, _DISM_EnableFeature, _DISM_GetPackages, _DISM_GetPackageInfo, _DISM_RemovePackage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824788.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismAddPackage(Session, "C:\\packages\\calc.cab", FALSE, FALSE, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_AddPackage($iSession, $sPackagePath, $bIgnoreCheck = False, $bPreventPending = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismAddPackage", _ "PTR", $iSession, _ "WSTR", $sPackagePath, _ "BOOL", $bIgnoreCheck, _ "BOOL", $bPreventPending, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismAddPackage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_AddPackage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_ApplyUnattend ; Description ...: Applies an unattended answer file to a Windows® image. ; Syntax.........: _DISM_ApplyUnattend($iSession, $sUnattendFile, $bSingleSession = True) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sUnattendFile - A relative or absolute path to the answer file that will be applied to the image. ; $bSingleSession - A Boolean value that specifies whether the packages that are listed in an answer file will be processed in a single session or in multiple sessions. ; | True - The unattended answer file will be processed in a single session. ; | False - All of the packages that are listed in the answer file will be processed in multiple sessions. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: When you use DISM to apply an answer file to an image, the unattended settings in the offlineServicing configuration pass are applied to the Windows image. For more information, see Unattended Servicing Command-Line Options. ; Related........: _DISM_AddDriver, _DISM_AddPackage, _DISM_EnableFeature ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh825840.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismApplyUnattend(Session, "C:\test\unattend.xml", TRUE); ; ; =============================================================================================================================== Func _DISM_ApplyUnattend($iSession, $sUnattendFile, $bSingleSession = True) Local $aResult = DllCall($ghdismapi, "LONG", "DismApplyUnattend", _ "PTR", $iSession, _ "WSTR", $sUnattendFile, _ "BOOL", $bSingleSession _ ) If @error Then Return SetError(@error, 0, "DismApplyUnattend") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_ApplyUnattend ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_CleanupMountpoints ; Description ...: Removes files and releases resources associated with corrupted or invalid mount paths. ; Syntax.........: _DISM_CleanupMountpoints() ; Parameters.....: ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_UnmountImage, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824743.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismCleanupMountpoints(); ; ; =============================================================================================================================== Func _DISM_CleanupMountpoints() Local $aResult = DllCall($ghdismapi, "LONG", "DismCleanupMountpoints") If @error Then Return SetError(@error, 0, "DismCleanupMountpoints") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_CleanupMountpoints ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_CloseSession ; Description ...: Closes a DISMSession created by DismOpenSession Function. This function does not unmount the image. To unmount the image, use the DismUnmountImage Function once all sessions are closed. ; Syntax.........: _DISM_CloseSession($iSession) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The DISMSession will be shut down after this call is completed but the image will not be unmounted. To unmount the image, use the DismUnmountImage Function once all sessions are closed. ; Related........: _DISM_OpenSession ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh825839.aspx ; Example .......; HRESULT hr = S_OK; ; DismSession session; ; hr = DismOpenSession( DISM_ONLINE_IMAGE, NULL, NULL, &session ); ; hr = DismCloseSession( session ); ; ; =============================================================================================================================== Func _DISM_CloseSession($iSession) Local $aResult = DllCall($ghdismapi, "LONG", "DismCloseSession", _ "PTR", $iSession _ ) If @error Then Return SetError(@error, 0, "DismCloseSession") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_CloseSession ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_CommitImage ; Description ...: Commits the changes made to a Windows® image in a mounted .wim or .vhd file. The image must be mounted using the DismMountImage Function. ; Syntax.........: _DISM_CommitImage($iSession, $iFlags = $DISM_COMMIT_IMAGE, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $iFlags - The commit flags to use for this operation. For more information about mount flags, see DISM API Constants. ; | $DISM_COMMIT_IMAGE - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should be saved. ; | $DISM_DISCARD_IMAGE - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should not be saved. ; | $DISM_COMMIT_GENERATE_INTEGRITY - Indicates to the DismCommitImage Function or the DismUnmountImage Function to set a flag on the image specifying whether the image is corrupted. ; | $DISM_COMMIT_APPEND - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should be saved. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The DismCommitImage function does not unmount the image. ; DismCommitImage can only be used on an image that is mounted within the DISM infrastructure. ; It does not apply to images mounted by another tool, such as the DiskPart tool, which are serviced using the DismOpenSession Function. ; You must use the DismMountImage Function to mount an image within the DISM infrastructure. ; Related........: _DISM_MountImage, _DISM_UnmountImage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh825835.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismCommitImage(Session, 0, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_CommitImage($iSession, $iFlags = $DISM_COMMIT_IMAGE, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismCommitImage", _ "PTR", $iSession, _ "DWORD", $iFlags, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismCommitImage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_CommitImage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_Delete ; Description ...: Releases resources held by a structure or an array of structures returned by other DISM API functions. ; Syntax.........: _DISM_Delete($pDismStructure) ; Parameters.....: $pDismStructure - A pointer to the structure, or array of structures, to be deleted. The structure must have been returned by an earlier call to a DISM API function. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: All structures that are returned by DISM API functions are allocated on the heap. The client must not delete or free these structures directly. ; Instead, the client should call DismDelete and pass in the pointer that was returned by the earlier DISM API call. ; Related........: ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824768.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismDelete(ImageInfo); ; ; =============================================================================================================================== Func _DISM_Delete($pDismStructure) Local $aResult = DllCall($ghdismapi, "LONG", "DismDelete", _ "PTR", $pDismStructure _ ) If @error Then Return SetError(@error, 0, "DismDelete") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_Delete ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_DisableFeature ; Description ...: Disables a feature in the current image. ; Syntax.........: _DISM_DisableFeature($iSession, $sFeatureName, $sPackageName = 0, $bRemovePayload = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sFeatureName - The name of the feature that you want to disable. To disable more than one feature, separate each feature name with a semicolon. ; $sPackageName - [optional] The name of the parent package that the feature is a part of. This is an optional parameter. If no package is specified, then the default Windows® Foundation package is used. ; $bRemovePayload - A Boolean value specifying whether to remove the files required to enable the feature. ; | True - The files are removed. ; | False - The files are not removed. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED (1). ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_EnableFeature, _DISM_GetFeatures, _DISM_GetFeatureInfo ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824766.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismDisableFeature(Session, "WindowsMediaPlayer", NULL, FALSE, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_DisableFeature($iSession, $sFeatureName, $sPackageName = 0, $bRemovePayload = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; control param passing Local $sType = "WSTR" If Not IsString($sPackageName) And $sPackageName = 0 Then $sType = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismDisableFeature", _ "PTR", $iSession, _ "WSTR", $sFeatureName, _ $sType, $sPackageName, _ "BOOL", $bRemovePayload, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismDisableFeature") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_DisableFeature ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_EnableFeature ; Description ...: Enables a feature in an image. Features are identified by a name and can optionally be tied to a package. ; Syntax.........: _DISM_EnableFeature($iSession, $sFeatureName, $sIdentifier = 0, $iPackageIdentifier = 0, $bLimitAccess = True, $sSourcePaths = 0, $iSourcePathCount = 0, $bEnableAll = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sFeatureName - The name of the feature that is being enabled. To enable more than one feature, separate each feature name with a semicolon. ; $sIdentifier - [optional] Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $iPackageIdentifier - [optional] Specifies whether a package is identified by name or by file path. ; | $DismPackageNone - No package is specified. ; | $DismPackageName - The package is identified by its name. ; | $DismDismPackagePath - The package is specified by its path. ; $bLimitAccess - A Boolean value indicating whether Windows Update (WU) should be contacted as a source location for downloading files if none are found in other specified locations. 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 required to enable the feature are still present on the computer, this flag is ignored. ; | True - Do not check WU for repair files. ; | False - Default. Check WU for repair files. ; $SourcePaths - [optional] A list of source locations to check for files needed to enable the feature. ; $SourcePathCount - [optional] The number of source locations specified. ; $bEnableAll - Enable all dependencies of the feature. If the specified feature or any one of its dependencies cannot be enabled, none of them will be changed from their existing state. ; | True - Enable all dependencies of the feature. ; | False - Only enable the specified feature. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED (1). ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: If the feature is present in the foundation package, you do not have to specify any package information. ; If the feature is in an optional package or feature pack that has already been installed in the image, specify a package name in the Identifier parameter and specify DismPackageName as the PackageIdentifier. ; If the feature cannot be enabled due to the parent feature not being enabled, a special error code will be returned. ; You can use EnableAll to enable the parent features when you enable the specified features, or you can use the DismGetFeatureParent Function to enumerate the parent features and enable them first. ; If the feature to be enabled is not a component of the foundation package, you must add the parent optional package with the DismAddPackage Function before you enable the feature. ; Do not you specify a path to a .cab file of an optional package that has not been added to the image in the Identifier parameter. ; If you specify a package that has not been added, and you specify DismPackagePath as the PackageIdentifier, the function will complete successfully but the feature will not be enabled. ; Related........: _DISM_AddPackage, _DISM_DisableFeature, _DISM_GetFeatures, _DISM_GetFeatureInfo ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824737.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismEnableFeature(Session, “WindowsMediaPlayer”, NULL, PackageNone, TRUE, NULL, 0, FALSE, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_EnableFeature($iSession, $sFeatureName, $sIdentifier = 0, $iPackageIdentifier = 0, $bLimitAccess = True, $sSourcePaths = 0, $iSourcePathCount = 0, $bEnableAll = False, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; control param passing Local $sType[2] = ["WSTR", "WSTR*"] If Not IsString($sIdentifier) And $sIdentifier = 0 Then $sType[0] = "PTR" If Not IsString($sSourcePaths) And $sSourcePaths = 0 Then $sType[1] = "PTR*" Local $aResult = DllCall($ghdismapi, "LONG", "DismEnableFeature", _ "PTR", $iSession, _ "WSTR", $sFeatureName, _ $sType[0], $sIdentifier, _ "INT", $iPackageIdentifier, _ "BOOL", $bLimitAccess, _ $sType[1], $sSourcePaths, _ "UINT", $iSourcePathCount, _ "BOOL", $bEnableAll, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismEnableFeature") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_EnableFeature ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetDriverInfo ; Description ...: Gets information about an .inf file in a specified image. ; Syntax.........: _DISM_GetDriverInfo($iSession, $sDriverPath, ByRef $vDriver, ByRef $vDriverPackage, $iDriverPackageInfo = 0, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sDriverPath - A relative or absolute path to the driver .inf file. ; $vDriver - [byref] Returns an object or array where: ; | $vDriver[0][0] - ManufacturerName - The manufacturer name of the driver. ; | $vDriver[0][1] - HardwareDescription - A hardware description of the driver. ; | $vDriver[0][2] - HardwareId - The hardware ID of the driver. ; | $vDriver[0][3] - Architecture - The architecture of the driver. ; | $vDriver[0][4] - ServiceName - The service name of the driver. ; | $vDriver[0][5] - CompatibleIds - The compatible IDs of the driver. ; | $vDriver[0][6] - ExcludeIds - The exclude IDs of the driver. ; $vDriverPackage - [byref, optional] A Reference to an object or array where: ; | $vDriverPackage[0][0] - PublishedName - The published driver name. ; | $vDriverPackage[0][1] - OriginalFileName - The original file name of the driver. ; | $vDriverPackage[0][2] - InBox - TRUE if the driver is included on the Windows distribution media and automatically installed as part of Windows®, otherwise FALSE. ; | $vDriverPackage[0][3] - CatalogFile - The catalog file for the driver. ; | $vDriverPackage[0][4] - ClassName - The class name of the driver. ; | $vDriverPackage[0][5] - ClassGuid - The class GUID of the driver. ; | $vDriverPackage[0][6] - ClassDescription - The class description of the driver. ; | $vDriverPackage[0][7] - BootCritical - TRUE if the driver is boot-critical, otherwise FALSE. ; | $vDriverPackage[0][8] - DriverSignature - The driver signature status. ; | $vDriverPackage[0][9] - ProviderName - The provider of the driver. ; | $vDriverPackage[0][10] - Date - The manufacturer's build date of the driver. ; | $vDriverPackage[0][11] - Version - Is composed of the following parameter: ; | MajorVersion - The major version number of the driver. ; | MinorVersion - The minor version number of the driver. ; | Build - The build number of the driver. ; | Revision - The revision number of the driver. ; $iDriverPackageInfo - A flag which determines, if driver package information will be processed. ; | True - Return extended driver information ; | False - No extended driver information ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: This function returns information about the .inf file installed on the image. The driver associated with the .inf file may or may not be installed in the image. ; Related........: _DISM_GetDrivers, _DISM_AddDriver, _DISM_RemoveDriver, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824733.aspx ; Example .......; HRESULT hr = S_OK; ; DismDriverInfo* DriverInfo; ; UINT Count; ; hr = DismGetDriverInfo(Session, L"usb.inf", &DriverInfo, &Count, &DriverPackageInfo); ; ; =============================================================================================================================== Func _DISM_GetDriverInfo($iSession, $sDriverPath, ByRef $vDriver, ByRef $vDriverPackage, $iDriverPackageInfo = 0, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetDriverInfo", _ "PTR", $iSession, _ "WSTR", $sDriverPath, _ "PTR*", 0, _ ; out "UINT*", 0, _ ; out "PTR*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetDriverInfo") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pDriver = $aResult[3], $iDriver = $aResult[4], $pDriverPackage = $aResult[5] ; get driver package data, if pointer not empty and DriverPackageInfo flag is true If $pDriverPackage <> 0 And $iDriverPackageInfo Then Local $tDriverPackage = DllStructCreate($tagDismDriverPackage, $pDriverPackage) ; create DismDriverPackage Structure Local $oDriverPackage = ObjCreate("Scripting.Dictionary") ; store driver package data in dictionay ; get driver package data $oDriverPackage.add("PublishedName", GetPCWSTR($tDriverPackage, "PublishedName")) $oDriverPackage.add("OriginalFileName", GetPCWSTR($tDriverPackage, "OriginalFileName")) $oDriverPackage.add("InBox", DllStructGetData($tDriverPackage, "InBox")) $oDriverPackage.add("CatalogFile", GetPCWSTR($tDriverPackage, "CatalogFile")) $oDriverPackage.add("ClassName", GetPCWSTR($tDriverPackage, "ClassName")) $oDriverPackage.add("ClassGuid", GetPCWSTR($tDriverPackage, "ClassGuid")) $oDriverPackage.add("ClassDescription", GetPCWSTR($tDriverPackage, "ClassDescription")) $oDriverPackage.add("BootCritical", DllStructGetData($tDriverPackage, "BootCritical")) $oDriverPackage.add("DriverSignature", _DISM_GetDriverSignature(DllStructGetData($tDriverPackage, "DriverSignature"))) $oDriverPackage.add("ProviderName", GetPCWSTR($tDriverPackage, "ProviderName")) $oDriverPackage.add("Date", GetSYSTEMTIME($tDriverPackage, 11)) #Region - Build Version Local $iMajorVersion = DllStructGetData($tDriverPackage, "MajorVersion"), $iMinorVersion = DllStructGetData($tDriverPackage, "MinorVersion"), $iBuild = DllStructGetData($tDriverPackage, "Build"), $iRevision = DllStructGetData($tDriverPackage, "Revision") $oDriverPackage.add("Version", $iMajorVersion & "." & $iMinorVersion & "." & $iBuild & "." & $iRevision) ; compose to version #EndRegion - Build Version ; free resources _DISM_Delete($tDriverPackage) $vDriverPackage = $oDriverPackage ; save dictionary to given parameter If $iOutputFormat = 1 Then Local $aDriverPackage[2][12], $i = 0 #Region - Create 2d-array For $sKey in $oDriverPackage.Keys $aDriverPackage[0][$i] = $sKey ; array title $aDriverPackage[1][$i] = $oDriverPackage($sKey) $i+=1 Next #EndRegion - Create 2d-array $vDriverPackage = $aDriverPackage ; save array to given parameter EndIf EndIf ; get driver data, if counter not 0 If $iDriver <> 0 Then Local $oDriverList = ObjCreate("System.Collections.ArrayList"), $tagDismDriver_tmp = "" For $i = 1 To $iDriver $tagDismDriver_tmp &= $tagDismDriver If $i = $iDriver Then ExitLoop $tagDismDriver_tmp &= ";" Next ; create DismDriver Structure Local $tDriver = DllStructCreate($tagDismDriver_tmp, $pDriver) For $_i = 1 To $iDriver Local $oDriver = ObjCreate("Scripting.Dictionary") ; store driver data in dictionay Local $tDriver_sub = DllStructCreate($tagDismDriver, DllStructGetPtr($tDriver, DetermineLocation($tagDismDriver, $_i, 1))) ; offset = 1 ; get driver data $oDriver.add("ManufacturerName", GetPCWSTR($tDriver_sub, "ManufacturerName")) $oDriver.add("Architecture", GetArchitecture(DllStructGetData($tDriver_sub, "Architecture"))) $oDriver.add("HardwareDescription", GetPCWSTR($tDriver_sub, "HardwareDescription")) $oDriver.add("HardwareId", GetPCWSTR($tDriver_sub, "HardwareId")) $oDriver.add("ServiceName", GetPCWSTR($tDriver_sub, "ServiceName")) $oDriver.add("CompatibleIds", GetPCWSTR($tDriver_sub, "CompatibleIds")) $oDriver.add("ExcludeIds", GetPCWSTR($tDriver_sub, "ExcludeIds")) $oDriverList.add($oDriver) ; add dict to list Next ; free resources _DISM_Delete($tDriver) _DISM_Delete($tDriver_sub) $vDriver = $oDriverList ; save list to given parameter If $iOutputFormat = 1 Then Local $aDriver[$iDriver+1][7], $j = 1 #Region - Create 2d-array For $oDriver in $oDriverList Local $i = 0 For $sKey in $oDriver.Keys If $j = 1 Then $aDriver[0][$i] = $sKey ; array title $aDriver[$j][$i] = $oDriver($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vDriver = $aDriver ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetDriverInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetDrivers ; Description ...: Lists the drivers in an image. ; Syntax.........: _DISM_GetDrivers($iSession, ByRef $vDriverPackage, $bAllDrivers = False, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $vDriverPackage - [byref] A Reference to an object or array where: ; | $vDriverPackage[0][0] - PublishedName - The published driver name. ; | $vDriverPackage[0][1] - OriginalFileName - The original file name of the driver. ; | $vDriverPackage[0][2] - InBox - TRUE if the driver is included on the Windows distribution media and automatically installed as part of Windows®, otherwise FALSE. ; | $vDriverPackage[0][3] - CatalogFile - The catalog file for the driver. ; | $vDriverPackage[0][4] - ClassName - The class name of the driver. ; | $vDriverPackage[0][5] - ClassGuid - The class GUID of the driver. ; | $vDriverPackage[0][6] - ClassDescription - The class description of the driver. ; | $vDriverPackage[0][7] - BootCritical - TRUE if the driver is boot-critical, otherwise FALSE. ; | $vDriverPackage[0][8] - DriverSignature - The driver signature status. ; | $vDriverPackage[0][9] - ProviderName - The provider of the driver. ; | $vDriverPackage[0][10] - Date - The manufacturer's build date of the driver. ; | $vDriverPackage[0][11] - Version - Is composed of the following parameter: ; | MajorVersion - The major version number of the driver. ; | MinorVersion - The minor version number of the driver. ; | Build - The build number of the driver. ; | Revision - The revision number of the driver. ; $bAllDrivers - A Boolean value specifying which drivers to retrieve. ; | True - Retrieve all drivers. ; | False - Retrieve only out-of-box drivers. Out-of-box drivers are drivers that were not originally included in the Windows image. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_AddDriver, _DISM_RemoveDriver, _DISM_GetDriverInfo, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824784.aspx ; Example .......; HRESULT hr = S_OK; ; DismDriver* DriverPackageInfos; ; UINT Count; ; hr = DismGetDrivers(Session, TRUE, &DriverPackageInfos, &Count); ; ; =============================================================================================================================== Func _DISM_GetDrivers($iSession, ByRef $vDriverPackage, $bAllDrivers = False, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetDrivers", _ "PTR", $iSession, _ "BOOL", $bAllDrivers, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetDrivers") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pDriverPackage = $aResult[3], $iDriverPackage = $aResult[4] ; get driver package data, if counter not 0 If $iDriverPackage <> 0 Then Local $oDriverPackageList = ObjCreate("System.Collections.ArrayList"), $tagDismDriverPackage_tmp = "" ; create array of DismDriverPackage Structure For $i = 1 To $iDriverPackage $tagDismDriverPackage_tmp &= $tagDismDriverPackage If $i = $iDriverPackage Then ExitLoop $tagDismDriverPackage_tmp &= ";" Next ; create DismDriverPackage Structure Local $tDriverPackage = DllStructCreate($tagDismDriverPackage_tmp, $pDriverPackage) For $_i = 1 To $iDriverPackage Local $oDriverPackage = ObjCreate("Scripting.Dictionary") ; store driver package data in dictionay Local $tDriverPackage_sub = DllStructCreate($tagDismDriverPackage, DllStructGetPtr($tDriverPackage, DetermineLocation($tagDismDriverPackage, $_i, 1))) ; offset = 1 ; get driver package data $oDriverPackage.add("PublishedName", GetPCWSTR($tDriverPackage_sub, "PublishedName")) $oDriverPackage.add("OriginalFileName", GetPCWSTR($tDriverPackage_sub, "OriginalFileName")) $oDriverPackage.add("InBox", DllStructGetData($tDriverPackage_sub, "InBox")) $oDriverPackage.add("CatalogFile", GetPCWSTR($tDriverPackage_sub, "CatalogFile")) $oDriverPackage.add("ClassName", GetPCWSTR($tDriverPackage_sub, "ClassName")) $oDriverPackage.add("ClassGuid", GetPCWSTR($tDriverPackage_sub, "ClassGuid")) $oDriverPackage.add("ClassDescription", GetPCWSTR($tDriverPackage_sub, "ClassDescription")) $oDriverPackage.add("BootCritical", DllStructGetData($tDriverPackage_sub, "BootCritical")) $oDriverPackage.add("DriverSignature", _DISM_GetDriverSignature(DllStructGetData($tDriverPackage_sub, "DriverSignature"))) $oDriverPackage.add("ProviderName", GetPCWSTR($tDriverPackage_sub, "ProviderName")) $oDriverPackage.add("Date", GetSYSTEMTIME($tDriverPackage_sub, 11)) #Region - Build Version Local $iMajorVersion = DllStructGetData($tDriverPackage_sub, "MajorVersion"), $iMinorVersion = DllStructGetData($tDriverPackage_sub, "MinorVersion"), $iBuild = DllStructGetData($tDriverPackage_sub, "Build"), $iRevision = DllStructGetData($tDriverPackage_sub, "Revision") $oDriverPackage.add("Version", $iMajorVersion & "." & $iMinorVersion & "." & $iBuild & "." & $iRevision) ; compose to version #EndRegion - Build Version $oDriverPackageList.add($oDriverPackage) ; add dict to list Next ; free resources _DISM_Delete($tDriverPackage) _DISM_Delete($tDriverPackage_sub) $vDriverPackage = $oDriverPackageList ; save list to given parameter If $iOutputFormat = 1 Then Local $aDriverPackage[$iDriverPackage+1][12], $j = 1 #Region - Create 2d-array For $oDriverPackage in $oDriverPackageList Local $i = 0 For $sKey in $oDriverPackage.Keys If $j = 1 Then $aDriverPackage[0][$i] = $sKey ; array title $aDriverPackage[$j][$i] = $oDriverPackage($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vDriverPackage = $aDriverPackage ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetDrivers ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetFeatureInfo ; Description ...: Gets detailed information for the specified feature. ; Syntax.........: _DISM_GetFeatureInfo($iSession, $sFeatureName, ByRef $vFeatureInfo, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sFeatureName - The name of the feature that you want to get more information about. ; $vFeatureInfo - [byref] A Reference to an object or array where: ; | $vFeatureInfo[0][0] - FeatureName - The name of the feature. ; | $vFeatureInfo[0][1] - FeatureState - Specifies the state of a package or a feature. ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as $DismStateResolved ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; | $vFeatureInfo[0][2] - DisplayName - The display name of the feature. This is not always unique across all features. ; | $vFeatureInfo[0][3] - Description - The description of the feature. ; | $vFeatureInfo[0][4] - RestartRequired - Specifies whether a restart is required after enabling a feature or installing a package. ; | $DismRestartNo - No restart is required. ; | $DismRestartPossible - This package or feature might require a restart. ; | $DismRestartRequired - This package or feature always requires a restart. ; | $vFeatureInfo[0][5] - CustomProperty - A Reference to an object or array where: ; | $aCustomProperty[0] - Name - The name of the custom property. ; | $aCustomProperty[1] - Value - The value of the custom property. ; | $aCustomProperty[2] - Path - The path of the custom property. ; | $vFeatureInfo[0][6] - CustomPropertyCount - The number of elements in the CustomProperty object/array. ; $sIdentifier - [optional] Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $iPackageIdentifier - [optional] Specifies whether a package is identified by name or by file path. ; | $DismPackageNone - No package is specified. ; | $DismPackageName - The package is identified by its name. ; | $DismDismPackagePath - The package is specified by its path. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: You can use this function to get the custom properties of a feature. If the feature has custom properties, they will be stored in the CustomProperty field as an array. Not all features have custom properties. ; Related........: _DISM_EnableFeature, _DISM_DisableFeature, _DISM_GetFeatureParent, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824735.aspx ; Example .......; HRESULT hr = S_OK; ; DismFeatureInfo FeatureInfo; hr = DismGetFeatureInfo(Session, "Xps-Foundation-Xps-Viewer", NULL, NULL, &FeatureInfo); ; ; =============================================================================================================================== Func _DISM_GetFeatureInfo($iSession, $sFeatureName, ByRef $vFeatureInfo, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; control param passing Local $sType = "WSTR" If Not IsString($sIdentifier) And $sIdentifier = 0 Then $sType = "PTR" Local $aResult = DllCall($ghdismapi, 0, "LONG", "DismGetFeatureInfo", _ "PTR", $iSession, _ "WSTR", $sFeatureName, _ $sType, $sIdentifier, _ "INT", $iPackageIdentifier, _ "PTR*", 0 _ ; out ) If @error Then Return SetError(@error, "DismGetFeatureInfo") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pFeatureInfo = $aResult[5] ; get feature info data, if pointer not empty If $pFeatureInfo <> 0 Then ; create DismFeatureInfo Structure Local $tFeatureInfo = DllStructCreate($tagDismFeatureInfo, $pFeatureInfo) Local $oFeatureInfo = ObjCreate("Scripting.Dictionary") ; store feature info data in dictionay ; get feature info data $oFeatureInfo.add("FeatureName", GetPCWSTR($tFeatureInfo, "FeatureName")) $oFeatureInfo.add("FeatureState", _DISM_GetPackageFeatureState(DllStructGetData($tFeatureInfo, "FeatureState"))) $oFeatureInfo.add("DisplayName", GetPCWSTR($tFeatureInfo, "DisplayName")) $oFeatureInfo.add("Description", GetPCWSTR($tFeatureInfo, "Description")) $oFeatureInfo.add("RestartRequired", _DISM_GetRestartType(DllStructGetData($tFeatureInfo, "RestartRequired"))) Local $iCustomProperty = DllStructGetData($tFeatureInfo, "CustomPropertyCount") ; get custom property data, if counter not 0 If $iCustomProperty <> 0 Then Local $oCustomPropertyList = ObjCreate("System.Collections.ArrayList"), $tagDismCustomProperty_tmp = "" ; create array of DismCustomProperty Structure For $i = 1 To $iCustomProperty $tagDismCustomProperty_tmp &= $tagDismCustomProperty If $i = $iCustomProperty Then ExitLoop $tagDismCustomProperty_tmp &= ";" Next ; create DismCustomProperty Structure Local $tCustomProperty = DllStructCreate($tagDismCustomProperty_tmp, DllStructGetData($tFeatureInfo, "CustomProperty")) For $_i = 1 To $iCustomProperty Local $oCustomProperty = ObjCreate("Scripting.Dictionary") ; store custom property data in dictionay ; create DismCustomProperty Structure Local $tCustomProperty_sub = DllStructCreate($tagDismCustomProperty, DllStructGetPtr($tCustomProperty, DetermineLocation($tagDismCustomProperty, $_i, 1))) ; offset = 1 ; get custom property data $oCustomProperty.add("Name", GetPCWSTR($tCustomProperty_sub, "Name")) $oCustomProperty.add("Value", GetPCWSTR($tCustomProperty_sub, "Value")) $oCustomProperty.add("Path", GetPCWSTR($tCustomProperty_sub, "Path")) $oCustomPropertyList.add($oCustomProperty) ; add dict to list Next ; free resources _DISM_Delete($tCustomProperty) _DISM_Delete($tCustomProperty_sub) $oFeatureInfo.add("CustomProperty", $oCustomPropertyList) $oFeatureInfo.add("CustomPropertyCount", $iCustomProperty) If $iOutputFormat = 1 Then Local $aCustomProperty[$iCustomProperty+1][3], $j = 1 #Region - Create 2d-array For $oCustomProperty in $oCustomPropertyList Local $i = 0 For $sKey in $oCustomProperty.Keys If $j = 1 Then $aCustomProperty[0][$i] = $sKey ; array title $aCustomProperty[$j][$i] = $oCustomProperty($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $oFeatureInfo.add("CustomProperty", $aCustomProperty) EndIf EndIf ; free resources _DISM_Delete($tFeatureInfo) $vFeatureInfo = $oFeatureInfo ; save dictionary to given parameter If $iOutputFormat = 1 Then Local $aFeatureInfo[2][5], $i = 0 #Region - Create 2d-array For $sKey in $oFeatureInfo.Keys $aFeatureInfo[0][$i] = $sKey ; array title $aFeatureInfo[1][$i] = $oFeatureInfo($sKey) $i+=1 Next #EndRegion - Create 2d-array $vFeatureInfo = $aFeatureInfo ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetFeatureInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetFeatureParent ; Description ...: Gets the parent features of a specified feature. ; Syntax.........: _DISM_GetFeatureParent($iSession, $sFeatureName, ByRef $vFeature, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sFeatureName - The name of the feature that you want to find the parent of. ; $vFeature - [byref] A Reference to an object or array where: ; | $vFeature[0][0] - FeatureName - The name of the feature. ; | $vFeature[0][1] - State - Specifies the state of a package or a feature. ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as $DismStateResolved ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; $sIdentifier - [optional] Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $iPackageIdentifier - [optional] Specifies whether a package is identified by name or by file path. ; | $DismPackageNone - No package is specified. ; | $DismPackageName - The package is identified by its name. ; | $DismDismPackagePath - The package is specified by its path. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: For a feature to be enabled, one or more of its parent features must be enabled. You can use this function to enumerate the parent features and determine which parent needs to be enabled. ; Related........: _DISM_EnableFeature, _DISM_DisableFeature, _DISM_GetFeatures, _DISM_GetFeatureInfo, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824798.aspx ; Example .......; HRESULT hr = S_OK; ; DismFeature* Feature; ; UINT FeatureCount; ; hr = DismGetFeatureParent(Session,"Xps-Foundation-Xps-Viewer", NULL, NULL, &Feature, &FeatureCount); ; ; =============================================================================================================================== Func _DISM_GetFeatureParent($iSession, $sFeatureName, ByRef $vFeature, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; control param passing Local $sType = "WSTR" If Not IsString($sIdentifier) And $sIdentifier = 0 Then $sType = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismGetFeatureParent", _ "PTR", $iSession, _ "WSTR", $sFeatureName, _ $sType, $sIdentifier, _ "INT", $iPackageIdentifier, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetFeatureParent") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pFeature = $aResult[5], $iFeature = $aResult[6] ; get feature data, if count not 0 If $iFeature <> 0 Then Local $oFeatureList = ObjCreate("System.Collections.ArrayList"), $agDismFeature_tmp = "" ; create array of DismFeature Structure For $i = 1 To $iFeature $agDismFeature_tmp &= $tagDismFeature If $i = $iFeature Then ExitLoop $agDismFeature_tmp &= ";" Next ; create DismFeature Structure Local $tFeature = DllStructCreate($agDismFeature_tmp, $pFeature) For $_i = 1 To $iFeature Local $oFeature = ObjCreate("Scripting.Dictionary") ; store feature data in dictionay Local $tFeature_sub = DllStructCreate($tagDismFeature, DllStructGetPtr($tFeature, DetermineLocation($tagDismFeature, $_i, 1))) ; offset = 1 ; get feature data $oFeature.add("FeatureName", GetPCWSTR($tFeature_sub, "FeatureName")) $oFeature.add("State", _DISM_GetPackageFeatureState(DllStructGetData($tFeature_sub, "State"))) $oFeatureList.add($oFeature) ; add dict to list Next ; free resources _DISM_Delete($tFeature) _DISM_Delete($tFeature_sub) $vFeature = $oFeatureList ; save list to given parameter If $iOutputFormat = 1 Then Local $aFeature[$iFeature+1][2], $j = 1 #Region - Create 2d-array For $oFeature in $oFeatureList Local $i = 0 For $sKey in $oFeature.Keys If $j = 1 Then $aFeature[0][$i] = $sKey ; array title $aFeature[$j][$i] = $oFeature($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vFeature = $aFeature ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetFeatureParent ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetFeatures ; Description ...: Gets all the features in an image, regardless of whether the features are enabled or disabled. ; Syntax.........: _DISM_GetFeatures($iSession, ByRef $vFeature, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $vFeature - [byref] A Reference to an object or array where: ; | $vFeature[0][0] - FeatureName - The name of the feature. ; | $vFeature[0][1] - State - Specifies the state of a package or a feature. ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as $DismStateResolved ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; $sIdentifier - [optional] Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $iPackageIdentifier - [optional] Specifies whether a package is identified by name or by file path. ; | $DismPackageNone - No package is specified. ; | $DismPackageName - The package is identified by its name. ; | $DismDismPackagePath - The package is specified by its path. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_EnableFeature, _DISM_DisableFeature, _DISM_GetFeatureInfo, _DISM_GetFeatureParent, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824771.aspx ; Example .......; HRESULT hr = S_OK; ; DismFeature* Feature; ; UINT FeatureCount; ; hr = DismGetFeatures(Session, NULL, NULL, &Feature, &FeatureCount); ; ; =============================================================================================================================== Func _DISM_GetFeatures($iSession, ByRef $vFeature, $sIdentifier = 0, $iPackageIdentifier = 0, $iOutputFormat = 0) ; control param passing Local $sType = "WSTR" If Not IsString($sIdentifier) And $sIdentifier = 0 Then $sType = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismGetFeatures", _ "PTR", $iSession, _ $sType, $sIdentifier, _ "INT", $iPackageIdentifier, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetFeatures") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pFeature = $aResult[4], $iFeature = $aResult[5] ; get feature data, if count not 0 If $iFeature <> 0 Then Local $oFeatureList = ObjCreate("System.Collections.ArrayList"), $agDismFeature_tmp = "" ; create array of DismFeature Structure For $i = 1 To $iFeature $agDismFeature_tmp &= $tagDismFeature If $i = $iFeature Then ExitLoop $agDismFeature_tmp &= ";" Next ; create DismFeature Structure Local $tFeature = DllStructCreate($agDismFeature_tmp, $pFeature) For $_i = 1 To $iFeature Local $oFeature = ObjCreate("Scripting.Dictionary") ; store feature data in dictionay Local $tFeature_sub = DllStructCreate($tagDismFeature, DllStructGetPtr($tFeature, DetermineLocation($tagDismFeature, $_i, 1))) ; offset = 1 ; get feature data $oFeature.add("FeatureName", GetPCWSTR($tFeature_sub, "FeatureName")) $oFeature.add("State", _DISM_GetPackageFeatureState(DllStructGetData($tFeature_sub, "State"))) $oFeatureList.add($oFeature) ; add dict to list Next ; free resources _DISM_Delete($tFeature) _DISM_Delete($tFeature_sub) $vFeature = $oFeatureList ; save list to given parameter If $iOutputFormat = 1 Then Local $aFeature[$iFeature+1][2], $j = 1 #Region - Create 2d-array For $oFeature in $oFeatureList Local $i = 0 For $sKey in $oFeature.Keys If $j = 1 Then $aFeature[0][$i] = $sKey ; array title $aFeature[$j][$i] = $oFeature($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vFeature = $aFeature ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetFeatures ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetLastErrorMessage ; Description ...: Retrieves the error message in the current thread immediately after a failure. ; Syntax.........: _DISM_GetLastErrorMessage(ByRef $sErrorMsg) ; Parameters.....: ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: You can retrieve a detailed error message immediately after a DISM API failure. The last error message is maintained on a per-thread basis. An error message on a thread will not overwrite the last error message on another thread. ; DismGetLastErrorMessage does not apply to the DismShutdown function, DismDelete function, or the DismGetLastErrorMessage function. ; You must call the DismDelete function to free the memory of ErrorMessage when the return value is S_OK. ; Related........: _DISM_GetErrorMesageText ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824754.aspx ; Example .......; Retrieve the error message in the current thread. ; HRESULT hr = S_OK; ; DismString* ErrorMessage; ; hr = DismGetLastErrorMessage(&ErrorMessage); ; ; =============================================================================================================================== Func _DISM_GetLastErrorMessage(ByRef $sErrorMsg) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetLastErrorMessage", _ "PTR*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetLastErrorMessage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pErrorMessage = $aResult[1] ; create DismString Structure Local $tErrorMessage = DllStructCreate($tagDismString, $pErrorMessage) Local $ptr = DllStructGetData($tErrorMessage, "Value") ; ptr ConsoleWrite($ptr) $sErrorMsg = GetPCWSTR($tErrorMessage, "Value") ; free resources _DISM_Delete($tErrorMessage) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetLastErrorMessage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetImageInfo ; Description ...: Returns an array of DismImageInfo Structure elements that describe the images in a .wim or .vhd file. ; Syntax.........: _DISM_GetImageInfo($sImageFilePath, ByRef $vImageInfo, $iImageIndex = Default, $iOutputFormat = 0) ; Parameters.....: $sImageFilePath - A relative or absolute path to a .wim or .vhd file. ; $vImageInfo - [byref] A Reference to an object or array where: ; | $vImageInfo[0][0] - ImageType - Specifies the file type of the Windows® image container. ; | Unsupported - The file type is unsupported. The image must be in a .wim, .vhd, or .vhdx file. ; | Wim - The image is in a .wim file. ; | Vhd - The image is in a .vhd or .vhdx file. ; | $vImageInfo[0][1] - ImageIndex - The index number, starting at 1, of the image. ; | $vImageInfo[0][2] - ImageName - The name of the image. ; | $vImageInfo[0][3] - ImageDescription - A description of the image. ; | $vImageInfo[0][4] - ImageSize - The size of the image in bytes. ; | $vImageInfo[0][5] - Architecture - The architecture of the image. ; | $vImageInfo[0][6] - ProductName - The name of the product, for example, "Microsoft Windows Operating System". ; | $vImageInfo[0][7] - EditionId - The edition of the product, for example, "Ultimate". ; | $vImageInfo[0][8] - InstallationType - A string identifying whether the installation is a Client or Server type. ; | $vImageInfo[0][9] - HAL - The hardware abstraction layer (HAL) type of the operating system. ; | $vImageInfo[0][10] - ProductType - The product type, for example, "WinNT". ; | $vImageInfo[0][11] - ProductSuite - The product suite, for example, "Terminal Server". ; | $vImageInfo[0][12] - Version - Is composed of the following parameter: ; | MajorVersion - The major version number of the driver. ; | MinorVersion - The minor version number of the driver. ; | Build - The build number of the driver. ; | $vImageInfo[0][13] - Service Pack-Build - The service pack build. ; | $vImageInfo[0][14] - Service Pack-Number - The service pack number. ; | $vImageInfo[0][15] - Bootable - Indicates whether an image is a bootable image type. ; | Yes - The image is bootable. ; | No - The image is not bootable. ; | Unknown - The image type is unknown. ; | $vImageInfo[0][16] - SystemRoot - The Windows directory. ; | $vImageInfo[0][17] - Language(s) - An array of DismLanguage Structure objects representing the languages in the image. ; | $vImageInfo[0][18] - DefaultLanguage - The default language. ; | $vImageInfo[0][19] - Size - The size of the DismWimCustomizedInfo structure. I Concatenated both array of structs. ; | $vImageInfo[0][20] - DirectoryCount - The number of directories in the image. ; | $vImageInfo[0][21] - FileCount - The number of files in the image. ; | $vImageInfo[0][22] - CreatedTime - The time that the image file was created. ; | $vImageInfo[0][23] - ModifiedTime - The time that the image file was last modified. ; $iImageIndex - The index of the image to retun. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The array of DismImageInfo structures are allocated by DISM API on the heap. ; You must call the DismDelete Function, passing the ImageInfo pointer, to free the resources associated with the DismImageInfo structures. ; Related........: _DISM_GetMountedImageInfo, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824767.aspx ; Example .......; HRESULT hr = S_OK; ; UINT* ImageInfoCount; ; hr = DismGetImageInfo(L"C:\\Images\\Image1.vhd", &ImageInfo, &ImageInfoCount); ; ; =============================================================================================================================== Func _DISM_GetImageInfo($sImageFilePath, ByRef $vImageInfo, $iImageIndex = Default, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetImageInfo", _ "WSTR", $sImageFilePath, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetImageInfo") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pImageInfo = $aResult[2], $iImageInfo = $aResult[3] Local $tagDismImageInfo = "INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;UINT Architecture;PTR ProductName;PTR EditionId;PTR InstallationType;" & _ "PTR Hal;PTR ProductType;PTR ProductSuite;UINT MajorVersion;UINT MinorVersion;UINT Build;UINT SpBuild;UINT SpLevel;INT Bootable;PTR SystemRoot;" & _ "PTR Language;UINT LanguageCount;UINT DefaultLanguageIndex;PTR CustomizedInfo" ; get image info data, if count not 0 If $iImageInfo <> 0 Then Local $oImageInfoList = ObjCreate("System.Collections.ArrayList"), $tagDismImageInfo_tmp = "" Local $iPropertyCount = 5 ; create array of DismImageInfo Structure For $i = 1 To $iImageInfo $tagDismImageInfo_tmp &= $tagDismImageInfo If $i = $iImageInfo Then ExitLoop $tagDismImageInfo_tmp &= ";" Next ; create DismImageInfo Structure Local $tImageInfo = DllStructCreate($tagDismImageInfo_tmp, $pImageInfo) ;~ _DLLStructDisplay($tImageInfo, $tagDismImageInfo_tmp, "Randomness") MsgBox(0, "ImageType", _DISM_GetImageType(DllStructGetData($tImageInfo, "ImageType"))) MsgBox(0, "ImageIndex", DllStructGetData($tImageInfo, "ImageIndex")) MsgBox(0, "ImageName", GetPCWSTR($tImageInfo, "ImageName")) MsgBox(0, "ImageDescription", GetPCWSTR($tImageInfo, "ImageDescription")) MsgBox(0, "ImageSize", DllStructGetData($tImageInfo, "ImageSize")) MsgBox(0, "Architecture", DllStructGetData($tImageInfo, "Architecture")) MsgBox(0, "ProductName", GetPCWSTR($tImageInfo, "ProductName")) ; autoit crashes MsgBox(0, "EditionId", DllStructGetData($tImageInfo, "EditionId")) MsgBox(0, "InstallationType", DllStructGetData($tImageInfo, "InstallationType")) MsgBox(0, "Hal", DllStructGetData($tImageInfo, "Hal")) MsgBox(0, "ProductType", DllStructGetData($tImageInfo, "ProductType")) MsgBox(0, "ProductSuite", DllStructGetData($tImageInfo, "ProductSuite")) MsgBox(0, "MajorVersion", DllStructGetData($tImageInfo, "MajorVersion")) MsgBox(0, "MinorVersion", DllStructGetData($tImageInfo, "MinorVersion")) MsgBox(0, "Build", DllStructGetData($tImageInfo, "Build")) MsgBox(0, "SpBuild", DllStructGetData($tImageInfo, "SpBuild")) MsgBox(0, "Lol", DllStructGetData($tImageInfo, "Lol")) MsgBox(0, "SystemRoot", DllStructGetData($tImageInfo, "SystemRoot")) MsgBox(0, "Language", DllStructGetData($tImageInfo, "Language")) MsgBox(0, "LanguageCount", DllStructGetData($tImageInfo, "LanguageCount")) MsgBox(0, "DefaultLanguageIndex", DllStructGetData($tImageInfo, "DefaultLanguageIndex")) MsgBox(0, "CustomizedInfo", DllStructGetData($tImageInfo, "CustomizedInfo")) For $_i = 1 To $iImageInfo Local $oImageInfo = ObjCreate("Scripting.Dictionary") ; store image info data in dictionay Local $tImageInfo_sub = DllStructCreate($tagDismImageInfo, DllStructGetPtr($tImageInfo, DetermineLocation($tagDismImageInfo, $_i, 1))) ;~ ; get image info data ;~ MsgBox(0, "index", $_i) ;~ MsgBox(0, "ImageType", _DISM_GetImageType(DllStructGetData($tImageInfo_sub, "ImageType"))) ;~ MsgBox(0, "ImageIndex", DllStructGetData($tImageInfo_sub, "ImageIndex")) ;~ MsgBox(0, "ImageName", GetPCWSTR($tImageInfo_sub, "ImageName")) ;~ MsgBox(0, "ImageDescription", GetPCWSTR($tImageInfo_sub, "ImageDescription")) ;~ MsgBox(0, "ImageSize", DllStructGetData($tImageInfo_sub, "ImageSize")) ;~ MsgBox(0, "Architecture", DllStructGetData($tImageInfo_sub, "Architecture")) ;~ MsgBox(0, "ProductName", GetPCWSTR($tImageInfo_sub, "ProductName")) ; autoit crashes ;~ Local $PCWSTR_struct = DllStructCreate("WCHAR[8]", DllStructGetData($tImageInfo_sub, "ProductName")) ; create struct with correct amount of bytes ;~ Local $PCWSTR = DllStructGetData($PCWSTR_struct, 1) ;~ MsgBox(0, "sddsf", $PCWSTR) ;~ MsgBox(0, "EditionId", DllStructGetData($tImageInfo_sub, "EditionId")) ;~ MsgBox(0, "InstallationType", DllStructGetData($tImageInfo_sub, "InstallationType")) ;~ MsgBox(0, "Hal", DllStructGetData($tImageInfo_sub, "Hal")) ;~ MsgBox(0, "ProductType", DllStructGetData($tImageInfo_sub, "ProductType")) ;~ MsgBox(0, "ProductSuite", DllStructGetData($tImageInfo_sub, "ProductSuite")) ;~ MsgBox(0, "MajorVersion", DllStructGetData($tImageInfo_sub, "MajorVersion")) ;~ MsgBox(0, "MinorVersion", DllStructGetData($tImageInfo_sub, "MinorVersion")) ;~ MsgBox(0, "Build", DllStructGetData($tImageInfo_sub, "Build")) ;~ MsgBox(0, "SpBuild", DllStructGetData($tImageInfo_sub, "SpBuild")) ;~ MsgBox(0, "Lol", DllStructGetData($tImageInfo_sub, "Lol")) ;~ MsgBox(0, "SystemRoot", DllStructGetData($tImageInfo_sub, "SystemRoot")) ;~ MsgBox(0, "Language", DllStructGetData($tImageInfo_sub, "Language")) ;~ MsgBox(0, "LanguageCount", DllStructGetData($tImageInfo_sub, "LanguageCount")) ;~ MsgBox(0, "DefaultLanguageIndex", DllStructGetData($tImageInfo_sub, "DefaultLanguageIndex")) ;~ MsgBox(0, "CustomizedInfo", DllStructGetData($tImageInfo_sub, "CustomizedInfo")) ;~ $oImageInfo.add("ImageType", _DISM_GetImageType(DllStructGetData($tImageInfo_sub, "ImageType"))) ;~ $oImageInfo.add("ImageIndex", DllStructGetData($tImageInfo_sub, "ImageIndex")) ;~ $oImageInfo.add("ImageName", GetPCWSTR($tImageInfo_sub, "ImageName")) ;~ $oImageInfo.add("ImageDescription", GetPCWSTR($tImageInfo_sub, "ImageDescription")) ;~ $oImageInfo.add("ImageSize", DllStructGetData($tImageInfo_sub, "ImageSize")) ;~ For $vKey In $oImageInfo ;~ ConsoleWrite("-> " & $vKey & " - " & $oImageInfo.Item($vKey) & @CRLF) ;~ Next ;~ ; these informations are only supported for: Windows® 7, Windows Server® 2008 R2, Windows PE 3.0, Windows® 8, Windows Server® 2012, Windows® Preinstallation Environment (Windows PE) 4.0 ;~ If $sWimFileVersion <> "WIN_10" Or $sWimFileVersion <> "WIN_2016" Then ;~ $iPropertyCount = 23 ;~ MsgBox(0, "dffs", "1") ;~ $oImageInfo.add("Architecture", GetArchitecture(DllStructGetData($tImageInfo_sub, "Architecture"))) ;~ $oImageInfo.add("ProductName", GetPCWSTR($tImageInfo_sub, "ProductName")) ;~ $oImageInfo.add("EditionId", GetPCWSTR($tImageInfo_sub, "EditionId")) ;~ $oImageInfo.add("InstallationType", GetPCWSTR($tImageInfo_sub, "InstallationType")) ;~ $oImageInfo.add("Hal", GetPCWSTR($tImageInfo_sub, "Hal")) ;~ $oImageInfo.add("ProductType", GetPCWSTR($tImageInfo_sub, "ProductType")) ;~ $oImageInfo.add("ProductSuite", GetPCWSTR($tImageInfo_sub, "ProductSuite")) ;~ #Region - Build Version ;~ Local $iMajorVersion = DllStructGetData($tImageInfo_sub, "MajorVersion"), $iMinorVersion = DllStructGetData($tImageInfo_sub, "MinorVersion"), $iBuild = DllStructGetData($tImageInfo_sub, "Build") ;~ $oImageInfo.add("Version", $iMajorVersion & "." & $iMinorVersion & "." & $iBuild) ; compose to version ;~ #EndRegion - Build Version ;~ $oImageInfo.add("Service Pack-Build", DllStructGetData($tImageInfo_sub, "SpBuild")) ;~ $oImageInfo.add("Service Pack-Level", DllStructGetData($tImageInfo_sub, "SpLevel")) ;~ $oImageInfo.add("Bootable", _DISM_GetImageBootable(DllStructGetData($tImageInfo_sub, "Bootable"))) ;~ $oImageInfo.add("SystemRoot", GetPCWSTR($tImageInfo_sub, "SystemRoot")) ;~ #Region - Get Language(s) ;~ Local $iLang = DllStructGetData($tImageInfo_sub, "LanguageCount"), $iDefaultLanguageIndex = DllStructGetData($tImageInfo_sub, "DefaultLanguageIndex") ;~ ; get custom property data, if counter not 0 ;~ If $iLang <> 0 Then ;~ Local $oLanguageList = ObjCreate("System.Collections.ArrayList"), $tagDismLanguage_tmp = "", $sLangString = "", $aLang[$iLang] ;~ ; create array of DismLanguage Structure ;~ For $i = 1 To $iLang ;~ $tagDismLanguage_tmp &= $tagDismLanguage ;~ If $i = $iLang Then ExitLoop ;~ $tagDismLanguage_tmp &= ";" ;~ Next ;~ ; create DismLanguage Structure ;~ Local $tLanguage = DllStructCreate($tagDismLanguage_tmp, DllStructGetData($tImageInfo_sub, "Language")) ;~ For $i = 1 To $iLang ;~ $aLang[$i-1] = GetPCWSTR($tLanguage, $i) ;~ $sLangString &= $aLang[$i-1] ;~ If $aLang[$i-1] = $iDefaultLanguageIndex Then $sLangString &= " " ;~ If $i = $iLang Then ExitLoop ;~ $sLangString &= ";" ;~ Next ;~ $oImageInfo.add("Language(s)", $sLangString) ;~ #EndRegion - Get Language(s) ;~ EndIf ;~ #Region - Customized Info ;~ Local $tCustomizedInfo = DllStructCreate($tagDismWimCustomizedInfo, DllStructGetData($tImageInfo_sub, "CustomizedInfo")) ; create DismWimCustomizedInfo Structure ;~ $oImageInfo.add("Size", DllStructGetData($tCustomizedInfo, "Size")) ;~ $oImageInfo.add("DirectoryCount", DllStructGetData($tCustomizedInfo, "DirectoryCount")) ;~ $oImageInfo.add("FileCount", DllStructGetData($tCustomizedInfo, "FileCount")) ;~ $oImageInfo.add("CreatedTime", GetSYSTEMTIME($tCustomizedInfo, 4)) ;~ $oImageInfo.add("ModifiedTime", GetSYSTEMTIME($tCustomizedInfo, 12)) ;~ #EndRegion - Customized Info ;~ $oImageInfoList.add($oImageInfo) ; add dict to list ;~ EndIf Next ; free resources, only for structures, which have been returned by an earlier call to a DISM API function _DISM_Delete($tImageInfo) _DISM_Delete($tImageInfo_sub) ;~ _DISM_Delete($tLanguage) ;~ _DISM_Delete($tCustomizedInfo) $vImageInfo = $oImageInfoList If $iOutputFormat = 1 Then #Region - Create 2d-array If $iImageIndex <> Default Then Local $oImageInfoList_tmp = ObjCreate("System.Collections.ArrayList") $oImageInfoList_tmp.add($oImageInfoList.Item($iImageIndex)) $oImageInfoList = $oImageInfoList_tmp EndIf Local $aImageInfo[$oImageInfoList.Count+1][$iPropertyCount], $j = 1 For $oImageInfo in $oImageInfoList Local $i = 0 For $sKey in $oImageInfo.Keys If $j = 1 Then $aImageInfo[0][$i] = $sKey ; array title $aImageInfo[$j][$i] = $oImageInfo($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vImageInfo = $aImageInfo Else If $iImageIndex <> Default Then $vImageInfo = $oImageInfoList.Item($iImageIndex-1) EndIf EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetImageInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetMountedImageInfo ; Description ...: Returns an array of DismMountedImageInfo Structure elements that describe the images that are mounted currently. ; Syntax.........: _DISM_GetMountedImageInfo(ByRef $vMountedImageInfo, $iOutputFormat = 0) ; Parameters.....: $vMountedImageInfo - [byref] A Reference to an object or array where: ; | $vMountedImageInfo[0][0] - MountPath - A relative or absolute path to the mounted image. ; | $vMountedImageInfo[0][1] - ImageFilePath - A relative or absolute path to the image file. ; | $vMountedImageInfo[0][2] - ImageIndex - The index number of the image. Index numbering starts at 1. ; | $vMountedImageInfo[0][3] - MountMode - Specifies whether an image is mounted as read-only or as read-write. ; | ReadWrite - Mounts an image in read-write mode. ; | ReadOnly - Mounts an image in read-only mode. ; | $vMountedImageInfo[0][4] - MountStatus - Indicates whether a mounted image needs to be remounted. ; | Ok - Indicates that the mounted image is mounted and ready for servicing. ; | NeedsRemount - Indicates that the mounted image needs to be remounted before being serviced. ; | Invalid - Indicates that the mounted image is corrupt and is in an invalid state. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: Only images mounted using the DISM infrastructure will be returned. If a .vhd file is mounted outside of DISM, such as with the DiskPart tool, ; this call will not return information about that image. You must use the DismMountImage Function to mount the image. ; The array of DismMountedImageInfo structures are allocated by the DISM API on the heap. ; You must call the DismDelete Function, passing the ImageInfo pointer, to free the resources associated with the DismImageInfo structures. ; Related........: _DISM_GetImageInfo, _DISM_MountImage, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824745.aspx ; Example .......; HRESULT hr = S_OK; ; DismMountedImageInfo* ImageInfo; ; UINT& ImageInfoCount; ; hr = DismGetMountedImageInfo(&ImageInfo, &ImageInfoCount); ; ; =============================================================================================================================== Func _DISM_GetMountedImageInfo(ByRef $vMountedImageInfo, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetMountedImageInfo", _ "PTR*", 0, _ ; out "UINT*", 0) ; out If @error Then Return SetError(@error, 0, "DismGetMountedImageInfo") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pMountedImageInfo = $aResult[1], $iMountedImageInfo = $aResult[2] ; get mounted image info data, if count not 0 If $iMountedImageInfo <> 0 Then Local $oMountedImageInfoList = ObjCreate("System.Collections.ArrayList"), $tagDismMountedImageInfo_tmp = "" ; create array of DismGetMountedImageInfo Structure For $i = 1 To $iMountedImageInfo $tagDismMountedImageInfo_tmp &= $tagDismMountedImageInfo If $i = $iMountedImageInfo Then ExitLoop $tagDismMountedImageInfo_tmp &= ";" Next ; create DismGetMountedImageInfo Structure Local $tMountedImageInfo = DllStructCreate($tagDismMountedImageInfo_tmp, $pMountedImageInfo) For $_i = 1 To $iMountedImageInfo Local $oMountedImageInfo = ObjCreate("Scripting.Dictionary") ; store image info data in dictionay Local $tMountedImageInfo_sub = DllStructCreate($tagDismMountedImageInfo, DllStructGetPtr($tMountedImageInfo, DetermineLocation($tagDismMountedImageInfo, $_i, 1))) ; get mounted image info data $oMountedImageInfo.add("MountPath", GetPCWSTR($tMountedImageInfo_sub, "MountPath")) $oMountedImageInfo.add("ImageFilePath", GetPCWSTR($tMountedImageInfo_sub, "ImageFilePath")) $oMountedImageInfo.add("ImageIndex", DllStructGetData($tMountedImageInfo_sub, "ImageIndex")) $oMountedImageInfo.add("MountMode", _DISM_GetMountMode(DllStructGetData($tMountedImageInfo_sub, "MountMode"))) $oMountedImageInfo.add("MountStatus", _DISM_GetMountStatus(DllStructGetData($tMountedImageInfo_sub, "MountStatus"))) $oMountedImageInfoList.add($oMountedImageInfo) ; add dict to list Next ; free resources _DISM_Delete($tMountedImageInfo) _DISM_Delete($tMountedImageInfo_sub) $vMountedImageInfo = $oMountedImageInfoList If $iOutputFormat = 1 Then Local $aMountedImageInfo[$iMountedImageInfo+1][5], $j = 1 #Region - Create 2d-array For $oMountedImageInfo in $oMountedImageInfoList Local $i = 0 For $sKey in $oMountedImageInfo.Keys If $j = 1 Then $aMountedImageInfo[0][$i] = $sKey ; array title $aMountedImageInfo[$j][$i] = $oMountedImageInfo($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vMountedImageInfo = $aMountedImageInfo EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetMountedImageInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetPackageInfo ; Description ...: Retrieves all of the standard package properties as the DismGetPackages Function, as well as more specific package information and custom properties. ; Syntax.........: _DISM_GetPackageInfo($iSession, $sIdentifier, ByRef $vPackageInfo, $iPackageIdentifier = $DismPackageName, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sIdentifier - Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $vPackageInfo - [byref] A Reference to an object or array where: ; | $vPackageInfo[0][0] - PackageName - The name of the package. ; | $vPackageInfo[0][1] - PackageState - Specifies the state of a package or a feature, see feature state above. ; | $vPackageInfo[0][2] - ReleaseType - Specifies the release type of a package. ; | CriticalUpdate - The package is a critical update. ; | Driver - The package is a driver. ; | FeaturePack - The package is a feature pack. ; | Hotfix - The package is a hotfix. ; | SecurityUpdate - The package is a security update. ; | SoftwareUpdate - The package is a software update. ; | Update - The package is a general update. ; | UpdateRollup - The package is an update rollup. ; | LanguagePack - The package is a language pack. ; | Foundation - The package is a foundation package. ; | ServicePack - The package is a service pack. ; | Product - The package is a product release. ; | LocalPack - The package is a local pack. ; | Other - The package is another type of release. ; | $vPackageInfo[0][3] - InstallTime - The date and time that the package was installed. This field is local time, based on the servicing host computer. ; | $vPackageInfo[0][4] - Applicable - TRUE if the package is applicable to the image, otherwise FALSE. ; | $vPackageInfo[0][5] - Copyright - The copyright information of the package. ; | $vPackageInfo[0][6] - Company - The company that released the package. ; | $vPackageInfo[0][7] - CreationTime - The date and time that the package was created. This field is local time, based on the time zone of the computer that created the package. ; | $vPackageInfo[0][8] - DisplayName - The display name of the package. ; | $vPackageInfo[0][9] - Description - A description of the purpose of the package. ; | $vPackageInfo[0][10] - InstallClient - The client that installed this package. ; | $vPackageInfo[0][11] - InstallPackageName - The original file name used for the package during installation. ; | $vPackageInfo[0][12] - LastUpdateTime - The date and time when this package was last updated. This field is local time, based on the servicing host computer. ; | $vPackageInfo[0][13] - ProductName - The product name for this package. ; | $vPackageInfo[0][14] - ProductVersion - The product version for this package. ; | $vPackageInfo[0][15] - RestartRequired - Specifies whether a restart is required after enabling a feature or installing a package. ; | No - No restart is required. ; | Possible - This package or feature might require a restart. ; | Required - This package or feature always requires a restart. ; | $vPackageInfo[0][16] - FullyOffline - Specifies whether a package can be installed to an offline image without booting the image. ; | Installable - The package can be installed to an offline image without booting the image. ; | NotInstallable - You must boot into the image in order to complete installation of this package. ; | InstallableUndetermined - You may have to boot the image in order to complete the installation of this package. ; | $vPackageInfo[0][17] - SupportInformation - A string listing additional support information for this package. ; | $vPackageInfo[0][18] - CustomProperty - A Reference to an object or array where: ; | $aCustomProperty[0] - Name - The name of the custom property. ; | $aCustomProperty[1] - Value - The value of the custom property. ; | $aCustomProperty[2] - Path - The path of the custom property. ; | $vPackageInfo[0][19] - CustomPropertyCount - The number of elements in the CustomProperty array. ; | $vPackageInfo[0][20] - Feature - A Reference to an object or array where: ; | $aFeature[0][0] - FeatureName - The name of the feature. ; | $aFeature[0][1] - State - Specifies the state of a package or a feature. ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as $DismStateResolved. ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; $iPackageIdentifier - Specifies whether a package is identified by name or by file path. ; | $DismPackageNone - No package is specified. ; | $DismPackageName - The package is identified by its name. ; | $DismPackagePath - The package is specified by its path. ; | $vPackageInfo[0][21] - FeatureCount - The number of elements in the Feature array. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: You can use this function to determine whether a package is applicable to the specified image. ; The DismPackageInfo Structure contains an Applicable field, which is a Boolean that returns TRUE if the package is applicable and FALSE if the package is not applicable to the specified image. ; Related........: _DISM_GetPackages, _DISM_RemovePackage, _DISM_AddPackage, _DISM_Delete ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824801.aspx ; Example .......; HRESULT hr = S_OK; ; DismPackageInfo PackageInfo; ; ; hr = DismGetPackageInfo(Session, "C:\packages\calc.cab", PackagePath, &PackageInfo); ; ; =============================================================================================================================== Func _DISM_GetPackageInfo($iSession, $sIdentifier, ByRef $vPackageInfo, $iPackageIdentifier = $DismPackageName, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetPackageInfo", _ "PTR", $iSession, _ "WSTR", $sIdentifier, _ "INT", $iPackageIdentifier, _ "PTR*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetPackageInfo") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pPackageInfo = $aResult[4] ; get pointer to struct ; get package info data, if pointer not empty If $pPackageInfo <> 0 Then ; create DismPackageInfo Structure Local $tPackageInfo = DllStructCreate($tagDismPackageInfo, $pPackageInfo) Local $oPackageInfo = ObjCreate("Scripting.Dictionary") ; store package info data in dictionay ; get package info data $oPackageInfo.add("PackageName", GetPCWSTR($tPackageInfo, "PackageName")) $oPackageInfo.add("PackageState", _DISM_GetPackageFeatureState(DllStructGetData($tPackageInfo, "PackageState"))) $oPackageInfo.add("ReleaseType", _DISM_GetReleaseType(DllStructGetData($tPackageInfo, "ReleaseType"))) $oPackageInfo.add("InstallTime", GetSYSTEMTIME($tPackageInfo, 4)) $oPackageInfo.add("Applicable", DllStructGetData($tPackageInfo, "Applicable")) $oPackageInfo.add("Copyright", GetPCWSTR($tPackageInfo, "Copyright")) $oPackageInfo.add("Company", GetPCWSTR($tPackageInfo, "Company")) $oPackageInfo.add("CreationTime", GetSYSTEMTIME($tPackageInfo, 15)) $oPackageInfo.add("DisplayName", GetPCWSTR($tPackageInfo, "DisplayName")) $oPackageInfo.add("Description", GetPCWSTR($tPackageInfo, "Description")) $oPackageInfo.add("InstallClient", GetPCWSTR($tPackageInfo, "InstallClient")) $oPackageInfo.add("InstallPackageName", GetPCWSTR($tPackageInfo, "InstallPackageName")) $oPackageInfo.add("LastUpdateTime", GetSYSTEMTIME($tPackageInfo, 27)) $oPackageInfo.add("ProductName", GetPCWSTR($tPackageInfo, "ProductName")) $oPackageInfo.add("ProductVersion", GetPCWSTR($tPackageInfo, "ProductVersion")) $oPackageInfo.add("RestartRequired", _DISM_GetRestartType(DllStructGetData($tPackageInfo, "RestartRequired"))) $oPackageInfo.add("FullyOffline", _DISM_GetFullyOfflineInstallableType(DllStructGetData($tPackageInfo, "FullyOffline"))) $oPackageInfo.add("SupportInformation", GetPCWSTR($tPackageInfo, "SupportInformation")) Local $iCustomProperty = DllStructGetData($tPackageInfo, "CustomPropertyCount") ; get custom property data, if count not 0 If $iCustomProperty <> 0 Then Local $oCustomPropertyList = ObjCreate("System.Collections.ArrayList"), $tagDismCustomProperty_tmp = "" ; create array of DismCustomProperty Structure For $i = 1 To $iCustomProperty $tagDismCustomProperty_tmp &= $tagDismCustomProperty If $i = $iCustomProperty Then ExitLoop $tagDismCustomProperty_tmp &= ";" Next ; create DismCustomProperty Structure Local $tCustomProperty = DllStructCreate($tagDismCustomProperty_tmp, DllStructGetData($tPackageInfo, "CustomProperty")) For $_i = 1 To $iCustomProperty Local $oCustomProperty = ObjCreate("Scripting.Dictionary") ; store custom property data in dictionay Local $tCustomProperty_sub = DllStructCreate($tagDismCustomProperty, DllStructGetPtr($tCustomProperty, DetermineLocation($tagDismCustomProperty, $_i, 1))) ; offset = 1 ; get custom property data $oCustomProperty.add("Name", GetPCWSTR($tCustomProperty_sub, "Name")) $oCustomProperty.add("Value", GetPCWSTR($tCustomProperty_sub, "Value")) $oCustomProperty.add("Path", GetPCWSTR($tCustomProperty_sub, "Path")) $oCustomPropertyList.add($oCustomProperty) ; add dict to list Next ; free resources _DISM_Delete($tCustomProperty) _DISM_Delete($tCustomProperty_sub) $oPackageInfo.add("CustomProperty", $oCustomPropertyList) $oPackageInfo.add("CustomPropertyCount", $iCustomProperty) If $iOutputFormat = 1 Then Local $aCustomProperty[$iCustomProperty+1][3], $j = 1 #Region - Create 2d-array For $oCustomProperty in $oCustomPropertyList Local $i = 0 For $sKey in $oCustomProperty.Keys If $j = 1 Then $aCustomProperty[0][$i] = $sKey ; array title $aCustomProperty[$j][$i] = $oCustomProperty($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $oPackageInfo.add("CustomProperty", $aCustomProperty) EndIf EndIf Local $iFeature = DllStructGetData($tPackageInfo, "FeatureCount") ; get feature data, if count not 0 If $iFeature <> 0 Then Local $oFeatureList = ObjCreate("System.Collections.ArrayList"), $agDismFeature_tmp = "" ; create array of DismFeature Structure For $i = 1 To $iFeature $agDismFeature_tmp &= $tagDismFeature If $i = $iFeature Then ExitLoop $agDismFeature_tmp &= ";" Next ; create DismFeature Structure Local $tFeature = DllStructCreate($agDismFeature_tmp, DllStructGetData($tPackageInfo, "Feature")) For $_j = 1 To $iFeature Local $oFeature = ObjCreate("Scripting.Dictionary") ; store feature data in dictionay Local $tFeature_sub = DllStructCreate($tagDismFeature, DllStructGetPtr($tFeature, DetermineLocation($tagDismFeature, $_j, 1))) ; offset = 1 ; get feature data $oFeature.add("FeatureName", GetPCWSTR($tFeature_sub, "FeatureName")) $oFeature.add("State", _DISM_GetPackageFeatureState(DllStructGetData($tFeature_sub, "State"))) $oFeatureList.add($oFeature) ; add dict to list Next ; free resources _DISM_Delete($tFeature) _DISM_Delete($tFeature_sub) $oPackageInfo.add("Feature", $oFeatureList) $oPackageInfo.add("FeatureCount", $iFeature) If $iOutputFormat = 1 Then Local $aFeature[$iFeature+1][2], $j = 1 #Region - Create 2d-array For $oFeature in $oFeatureList Local $i = 0 For $sKey in $oFeature.Keys If $j = 1 Then $aFeature[0][$i] = $sKey ; array title $aFeature[$j][$i] = $oFeature($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $oPackageInfo.add("Feature", $aFeature) EndIf EndIf ; free resources _DISM_Delete($tPackageInfo) $vPackageInfo = $oPackageInfo ; save the dictionary to given parameter If $iOutputFormat = 1 Then Local $aPackageInfo[2][22], $i = 0 #Region - Create 2d-array For $sKey in $oPackageInfo.Keys $aPackageInfo[0][$i] = $sKey ; array title $aPackageInfo[1][$i] = $oPackageInfo($sKey) $i+=1 Next #EndRegion - Create 2d-array $vPackageInfo = $aPackageInfo EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetPackageInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetPackages ; Description ...: Lists each package in an image and provides basic information about each package, such as the package name and type of package. ; Syntax.........: _DISM_GetPackages($iSession, ByRef $vPackage, $iOutputFormat = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $vPackage - [byref] A Reference to an object or array where: ; | $vPackage[0][0] - PackageName - The name of the package. ; | $vPackage[0][1] - PackageState - Specifies the state of a package or a feature. ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as $DismStateResolved. ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; | $vPackage[0][2] - ReleaseType - Specifies the release type of a package. ; | CriticalUpdate - The package is a critical update. ; | Driver - The package is a driver. ; | FeaturePack - The package is a feature pack. ; | Hotfix - The package is a hotfix. ; | SecurityUpdate - The package is a security update. ; | SoftwareUpdate - The package is a software update. ; | Update - The package is a general update. ; | UpdateRollup - The package is an update rollup. ; | LanguagePack - The package is a language pack. ; | Foundation - The package is a foundation package. ; | ServicePack - The package is a service pack. ; | Product - The package is a product release. ; | LocalPack - The package is a local pack. ; | Other - The package is another type of release. ; | $vPackage[0][3] - InstallTime - The date and time that the package was installed. This field is local time, based on the servicing host computer. ; $iOutputFormat - A flag which determines, if an object or array is returned. ; | 0 - Returns an object (dictionary or list) ; | 1 - Return an 2d-array ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: When you are finished with the Package array, you must remove it by using the DismDelete Function. ; Related........: _DISM_Delete, _DISM_GetPackageInfo, _DISM_RemovePackage, _DISM_AddPackage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824759.aspx ; Example .......; HRESULT hr = S_OK; ; DismPackage* Package = NULL; ; UINT Count = 0; ; hr = DismGetPackages(Session, &Package, &Count); ; ; =============================================================================================================================== Func _DISM_GetPackages($iSession, ByRef $vPackage, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismGetPackages", _ "PTR", $iSession, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismGetPackages") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pPackage = $aResult[2], $iPackage = $aResult[3] ; get package data, if counter not 0 If $iPackage <> 0 Then Local $oPackageList = ObjCreate("System.Collections.ArrayList"), $tagDismPackage_tmp = "" ; Create array of DismPackage Structure For $i = 1 To $iPackage $tagDismPackage_tmp &= $tagDismPackage If $i = $iPackage Then ExitLoop $tagDismPackage_tmp &= ";" Next ; Create DismPackage Structure Local $tPackage = DllStructCreate($tagDismPackage_tmp, $pPackage) For $_i = 1 To $iPackage Local $oPackage = ObjCreate("Scripting.Dictionary") ; store package data in dictionay Local $tPackage_sub = DllStructCreate($tagDismPackage, DllStructGetPtr($tPackage, DetermineLocation($tagDismPackage, $_i, 1))) ; get package data $oPackage.add("PackageName", GetPCWSTR($tPackage_sub, "PackageName")) $oPackage.add("PackageState", _DISM_GetPackageFeatureState(DllStructGetData($tPackage_sub, "PackageState"))) $oPackage.add("ReleaseType", _DISM_GetReleaseType(DllStructGetData($tPackage_sub, "ReleaseType"))) $oPackage.add("InstallTime", GetSYSTEMTIME($tPackage_sub, 4)) $oPackageList.add($oPackage) ; add dict to list Next ; free resources _DISM_Delete($tPackage) _DISM_Delete($tPackage_sub) $vPackage = $oPackageList ; save list to given parameter If $iOutputFormat = 1 Then Local $aPackage[$iPackage+1][4], $j = 1 #Region - Create 2d-array For $oPackage in $oPackageList Local $i = 0 For $sKey in $oPackage.Keys If $j = 1 Then $aPackage[0][$i] = $sKey ; array title $aPackage[$j][$i] = $oPackage($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vPackage = $aPackage ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_GetPackages Func _DismGetProvisionedAppxPackages($iSession, ByRef $vPackage, $iOutputFormat = 0) Local $aResult = DllCall($ghdismapi, "LONG", "_DismGetProvisionedAppxPackages", _ "PTR", $iSession, _ "PTR*", 0, _ ; out "UINT*", 0 _ ; out ) ;~ If @error Then Return SetError(@error, 0, "_DismGetProvisionedAppxPackages") ;~ If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Local $pPackage = $aResult[2], $iPackage = $aResult[3] ;~ _ArrayDisplay($aResult) ; get package data, if counter not 0 If $iPackage <> 0 Then Local $oPackageList = ObjCreate("System.Collections.ArrayList"), $tagDismApp_tmp = "" ; Create array of DismPackage Structure For $i = 1 To $iPackage $tagDismApp_tmp &= $tagDismApp If $i = $iPackage Then ExitLoop $tagDismApp_tmp &= ";" Next ; Create DismPackage Structure Local $tPackage = DllStructCreate($tagDismApp_tmp, $pPackage) ;~ _DLLStructDisplay($tPackage, $tagDismApp_tmp, "Randomness") For $_i = 1 To $iPackage Local $oPackage = ObjCreate("Scripting.Dictionary") ; store package data in dictionay Local $tPackage_sub = DllStructCreate($tagDismApp, DllStructGetPtr($tPackage, DetermineLocation($tagDismApp, $_i, 1))) _DLLStructDisplay($tPackage_sub, $tagDismApp, "Randomness") MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "PackageName")) MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "DisplayName")) MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "PublisherId")) MsgBox(0, "dsfsf", DllStructGetData($tPackage_sub, "ResID")) MsgBox(0, "dsfsf", DllStructGetData($tPackage_sub, "ResID2")) MsgBox(0, "dsfsf", DllStructGetData($tPackage_sub, "ResID3")) MsgBox(0, "dsfsf", DllStructGetData($tPackage_sub, "ResID4")) MsgBox(0, "dsfsf", DllStructGetData($tPackage_sub, "Name")) MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "Name1")) MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "Name2")) ;~ MsgBox(0, "dsfsf", GetPCWSTR($tPackage_sub, "Name3")) MsgBox(0, "sdfsf", "dsfsf") ; get package data $oPackage.add("PackageName", GetPCWSTR($tPackage_sub, "PackageName")) $oPackage.add("Version", GetPCWSTR($tPackage_sub, "Version")) $oPackage.add("Architecture", DllStructGetData($tPackage_sub, "Architecture")) $oPackage.add("ResID", GetPCWSTR($tPackage_sub, "ResID")) $oPackage.add("Name", GetPCWSTR($tPackage_sub, "Name")) $oPackageList.add($oPackage) ; add dict to list Next ; free resources _DISM_Delete($tPackage) _DISM_Delete($tPackage_sub) $vPackage = $oPackageList ; save list to given parameter If $iOutputFormat = 1 Then Local $aPackage[$iPackage+1][4], $j = 1 #Region - Create 2d-array For $oPackage in $oPackageList Local $i = 0 For $sKey in $oPackage.Keys If $j = 1 Then $aPackage[0][$i] = $sKey ; array title $aPackage[$j][$i] = $oPackage($sKey) $i+=1 Next $j+=1 Next #EndRegion - Create 2d-array $vPackage = $aPackage ; save array to given parameter EndIf EndIf Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_Initialize ; Description ...: Initializes DISM API. DismInitialize must be called once per process before calling any other DISM API functions. ; Syntax.........: _DISM_Initialize($iLogLevel, $sLogFilePath = 0, $sScratchDirectory = 0) ; Parameters.....: $iLogLevel - Specifies the kind of information that is reported in the log file. ; | $DismLogErrors - Log file only contains errors. ; | $DismLogErrorsWarnings - Log file contains errors and warnings. ; | $DismLogErrorsWarningsInfo - Log file contains errors, warnings, and additional information. ; $sLogFilePath - [optional] A relative or absolute path to a log file. All messages generated will be logged to this path. If NULL, the default log path, %windir%\Logs\DISM\dism.log, will be used. ; $sScratchDirectory - [optional] A relative or absolute path to a scratch directory. DISM API will use this directory for internal operations. If NULL, the default temp directory, \Windows\%Temp%, will be used. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The client code must call DismInitialize once per process. DISM API will serialize concurrent calls to DismInitialize. ; The first call will succeed and the others will fail. For more information, see Using the DISM API. ; Related........: _DISM_Shutdown ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824803.aspx ; Example .......; HRESULT hr = S_OK; ; DismLogLevel Level = DismLogErrorsWarningsInfo; ; hr = DismInitialize(Level, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_Initialize($iLogLevel, $sLogFilePath = 0, $sScratchDirectory = 0) ; control param passing Local $sType[2] = ["WSTR", "WSTR"] If Not IsString($sLogFilePath) And $sLogFilePath = 0 Then $sType[0] = "PTR" If Not IsString($sScratchDirectory) And $sScratchDirectory = 0 Then $sType[1] = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismInitialize", _ "INT", $iLogLevel, _ $sType[0], $sLogFilePath, _ $sType[1], $sScratchDirectory _ ) If @error Then Return SetError(@error, 0, "DismInitialize") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_Initialize ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_MountImage ; Description ...: Returns an array of DismMountedImageInfo Structure elements that describe the images that are mounted currently. ; Syntax.........: _DISM_MountImage($sImageFilePath, $sMountPath, $iImageIndex, $iFlags = $DISM_MOUNT_READONLY, $sImageName = 0, $iImageIdentifier = $DismImageIndex, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $sImageFilePath - The path to the WIM or VHD file on the local computer. A .wim, .vhd, or .vhdx file name extension is required. ; $sMountPath - The path of the location where the image should be mounted. This mount path must already exist on the computer. The Windows image in a .wim, .vhd, or .vhdx file can be mounted to an empty folder on an NTFS formatted drive. A Windows image in a .vhd or .vhdx file can also be mounted to an unassigned drive letter. You cannot mount an image to the root of the existing drive. ; $iImageIndex - The index of the image in the WIM file that you want to mount. For a VHD file, you must specify an index of 1. ; $iFlags - The mount flags to use for this operation. For more information about mount flags, see DISM API Constants. ; | $DISM_MOUNT_READWRITE - Indicates to the DismMountImage Function that the image should be mounted with both read and write access. ; | $DISM_MOUNT_READONLY - Indicates to the DismMountImage Function that the image should be mounted with read access only. ; | $DISM_MOUNT_OPTIMIZE - Indicates to the DismMountImage Function that the image should be mounted with optimization. When the optimize option is used, only the top level of the file directory in the image will be mapped to the mount location. The first time that you access a file path that is not initially mapped, that branch of the directory will be mounted. As a result, there may be an increase in the time that is required to access a directory for the first time after mounting an image using the optimize option. ; | $DISM_MOUNT_CHECK_INTEGRITY - Indicates to the DismMountImage Function to set a flag on the image specifying whether the image is corrupted. ; $sImageName - [optional] The name of the image that you want to mount. ; $iImageIdentifier - A DismImageIdentifier Enumeration value such as DismImageIndex. ; | $DismImageIndex - Identify the image by index number. ; | $DismImageName - Identify the image by name. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: After mounting an image, use the DismOpenSession Function to start a servicing session. For more information, see Using the DISM API. ; Mounting an image from a WIM or VHD file that is stored on the network is not supported. You must specify a file on the local computer. ; To mount an image from a VHD file, you must specify an ImageIndex of 1. ; The MountPath must be a file path that already exists on the computer. Images in WIM and VHD files can be mounted to an empty folder on an NTFS formatted drive. ; You can also mount an image from a VHD file to an unassigned drive letter. You cannot mount an image to the root of the existing drive. ; When mounting an image in a WIM file, the image can either be identified by the image index number specified by ImageIndex, or the name of the image specified by ImageName. ; ImageIdentifier specifies whether to use the ImageIndex or ImageName parameter to identify the image. ; Related........: _DISM_OpenSession, _DISM_UnmountImage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824731.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismMountImage(L” C:\\test\\images\\myimage.wim”, L"C:\\test\\offline", 1, NULL, DismImageIndex, DISM_MOUNT_READWRITE, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_MountImage($sImageFilePath, $sMountPath, $iImageIndex, $iFlags = $DISM_MOUNT_READONLY, $sImageName = 0, $iImageIdentifier = $DismImageIndex, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; control param passing Local $sType = "WSTR" If Not IsString($sImageName) And $sImageName = 0 Then $sType = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismMountImage", _ "WSTR", $sImageFilePath, _ "WSTR", $sMountPath, _ "UINT", $iImageIndex, _ $sType, $sImageName, _ "INT", $iImageIdentifier, _ "DWORD", $iFlags, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismMountImage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_MountImage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_OpenSession ; Description ...: Associates an offline or online Windows image with a DISMSession. ; Syntax.........: _DISM_OpenSession($sImagePath, ByRef $iSession, $WindowsDirectory = 0, $sSystemDrive = 0) ; Parameters.....: $sImagePath - Set ImagePath to one of the following values: ; | An absolute or relative path to the root directory of an offline Windows image. ; | An absolute or relative path to the root directory of a mounted Windows image. You can mount the image before calling DismOpenSession by using an external tool or by using the DismMountImage Function. ; | DISM_ONLINE_IMAGE to associate the DISMSession with the online Windows installation. ; $iSession - [byref] A pointer to a valid DISMSession. The DISMSession will be associated with the image after this call is successfully completed. ; $WindowsDirectory - [optional] A relative or absolute path to the Windows directory. The path is relative to the mount point. ; If the value of WindowsDirectory is NULL, the default value of Windows is used. ; Note: The WindowsDirectory parameter cannot be used when the ImagePath parameter is set to DISM_ONLINE_IMAGE. ; $sSystemDrive - [optional] The letter of the system drive that contains the boot manager. If SystemDrive is NULL, the default value of the drive containing the mount point is used. ; Note: The SystemDrive parameter cannot be used when the ImagePath parameter is set to DISM_ONLINE_IMAGE. ; Return values..: Success - Returns a valid DISMSession. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The DISMSession can be used to service the image after the DISMOpenSession call is successfully completed. ; The DISMSession must be shut down by calling the DismCloseSession Function. ; Related........: _DISM_CloseSession, _DISM_MountImage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824800.aspx ; Example .......; HRESULT hr = S_OK; ; DismSession Session = DISM_SESSION_DEFAULT; ; hr = DismOpenSession(L"C:\\Mount\\", NULL, NULL, &Session); ; ; =============================================================================================================================== Func _DISM_OpenSession($sImagePath, ByRef $iSession, $WindowsDirectory = 0, $sSystemDrive = 0) ; control param passing Local $sType[2] = ["WSTR", "WSTR"] If Not IsString($WindowsDirectory) And $WindowsDirectory = 0 Then $sType[0] = "PTR" If Not IsString($sSystemDrive) And $sSystemDrive = 0 Then $sType[1] = "PTR" Local $aResult = DllCall($ghdismapi, "LONG", "DismOpenSession", _ "WSTR", $sImagePath, _ $sType[0], $WindowsDirectory, _ $sType[1], $sSystemDrive, _ "PTR*", 0 _ ; out ) If @error Then Return SetError(@error, 0, "DismOpenSession") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) ; get session, if session not 0 If $aResult[4] <> 0 Then $iSession = $aResult[4] Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_OpenSession ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_RemountImage ; Description ...: Remounts a Windows image from the .wim or .vhd file that was previously mounted at the path specified by MountPath. Use the DismOpenSession Function to associate the image with a DISMSession after it is remounted. ; You can use the DismRemountImage function when the image is in the DismMountStatusNeedsRemount state, as described by the DismMountStatus Enumeration. The image may enter this state if it is mounted and then a reboot occurs. ; Syntax.........: _DISM_RemountImage($sMountPath) ; Parameters.....: $sMountPath - A relative or absolute path to the mount directory of the image. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Note: Returns $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_REMOUNT_IMAGE_PATH. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_MountImage, _DISM_UnmountImage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824778.aspx ; Example .......; HRESULT hr = S_OK; ; DismSession* Session = NULL; ; hr = DismRemountImage(L"C:\\Mount\\"); ; ; =============================================================================================================================== Func _DISM_RemountImage($sMountPath) Local $aResult = DllCall($ghdismapi, "LONG", "DismRemountImage", _ "WSTR", $sMountPath _ ) If @error Then Return SetError(@error, 0, "DismRemountImage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_RemountImage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_RemoveDriver ; Description ...: Removes an out-of-box driver from an offline image. ; Syntax.........: _DISM_RemoveDriver($iSession, $sDriverPath) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sDriverPath - The published file name of the driver that has been added to the image, for example OEM1.inf. You can use the DismGetDrivers Function to get the published name of the driver. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: This function only supports offline images. ; Removing a boot-critical driver can make the offline Windows image unbootable. ; Related........: _DISM_AddDriver ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824729.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismRemoveDriver(Session, "Oem1.inf"); ; ; =============================================================================================================================== Func _DISM_RemoveDriver($iSession, $sDriverPath) Local $aResult = DllCall($ghdismapi, "LONG", "DismRemoveDriver", _ "PTR", $iSession, _ "WSTR", $sDriverPath _ ) If @error Then Return SetError(@error, 0, "DismRemoveDriver") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_RemoveDriver ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_RemovePackage ; Description ...: Removes a package from an image. ; Syntax.........: _DISM_RemovePackage($iSession, $sIdentifier, $iPackageIdentifier = $DismPackageName, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $iSession - A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function. ; $sIdentifier - Either an absolute path to a .cab file or the package name, depending on the PackageIdentifier parameter value. ; $iPackageIdentifier - The parameter for a DismPackageIdentifier Enumeration. ; | $DismPackageName - Use this value when you want to specify a package by using the package name. ; | $DismPackagePath - Use this value when you want to specify a package by using an absolute path to a .cab file. ; | $DismPackageNone - Is not a valid value for this function. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: The DismRemovePackage function does not support .msu files. ; Related........: _DISM_AddPackage, _DISM_GetPackages, _DISM_RemoveDriver, _DISM_DisableFeature ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824732.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismRemovePackage(Session, "C:\\packages\\test.CAB", PackagePath, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_RemovePackage($iSession, $sIdentifier, $iPackageIdentifier = $DismPackageName, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismRemovePackage", _ "PTR", $iSession, _ "WSTR", $sIdentifier, _ "INT", $iPackageIdentifier, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismRemovePackage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_RemovePackage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_Shutdown ; Description ...: Shuts down DISM API. DismShutdown must be called once per process. Other DISM API function calls will fail after DismShutdown has been called. ; Syntax.........: _DISM_Shutdown() ; Parameters.....: ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Note: Returns $DISMAPI_E_DISMAPI_NOT_INITIALIZED if the DismInitialize Function has not been called. ; Returns $DISMAPI_E_OPEN_SESSION_HANDLES if any open DISMSession have not been closed. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: You must call DismShutdown once per process. Calls to DismShutdown must be matched to an earlier call to the DismInitialize Function. ; DISM API will serialize concurrent calls to DismShutdown. The first call will succeed and the other calls will fail. ; Before calling DismShutdown, you must close all DISMSession using the DismCloseSession Function. If there are open DismSessions when calling DismShutdown, then the DismShutdown call will fail. ; For more information, see Using the DISM API. ; Related........: _DISM_Initialize, _DISM_CloseSession ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824773.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismShutdown(); ; ; =============================================================================================================================== Func _DISM_Shutdown() Local $aResult = DllCall($ghdismapi, "LONG", "DismShutdown") If @error Then Return SetError(@error, 0, "DismShutdown") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_Shutdown ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_UnmountImage ; Description ...: Unmounts a Windows image from a specified location. ; Syntax.........: _DISM_UnmountImage($sMountPath, $iFlags = $DISM_DISCARD_IMAGE, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) ; Parameters.....: $sMountPath - A relative or absolute path to the mount directory of the image. ; $iFlags - The unmount flags to use for this operation. For more information about unmount flags, see DISM API Constants. ; | $DISM_COMMIT_IMAGE - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should be saved. ; | $DISM_DISCARD_IMAGE - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should not be saved. ; | $DISM_COMMIT_GENERATE_INTEGRITY - Indicates to the DismCommitImage Function or the DismUnmountImage Function to set a flag on the image specifying whether the image is corrupted. ; | $DISM_COMMIT_APPEND - Indicates to the DismCommitImage Function or the DismUnmountImage Function that changes to the image should be saved. ; | $DISM_COMMIT_MASK - Indicates to the DismUnmountImage Function that all changes should be saved. This flag is equivalent to using DISM_COMMIT_IMAGE, DISM_COMMIT_GENERATE_INTEGRITY, and DISM_COMMIT_APPEND. ; $hCancelEvent - [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. ; $pProgress - [optional] A pointer to a client-defined DismProgressCallback Function. ; $vUserData - [optional] User defined custom data. ; Return values..: Success - Returns $DISM_S_OK. ; Failure - Returns $aResult[0] and sets the @error flag to non-zero. ; Both - Sets @extended to _WinAPI_GetLastError(). ; Author(s)......: André Cut ; Modified.......: ; Remarks........: After you use the DismCloseSession Function to end every active DISMSession, you can unmount the image using the DismUnmountImage function. ; Related........: _DISM_MountImage, _DISM_CloseSession, _DISM_RemountImage ; Link ..........; http://msdn.microsoft.com/en-us/library/windows/desktop/hh824802.aspx ; Example .......; HRESULT hr = S_OK; ; hr = DismMountImage(L” C:\\test\\images\\myimage.wim”, L"C:\\test\\offline", 1, NULL, DismImageIndex, DISM_MOUNT_READWRITE, NULL, NULL, NULL); ; hr = DismUnmountImage (L"C:\\test\\offline", DISM_COMMIT_IMAGE, NULL, NULL, NULL); ; ; =============================================================================================================================== Func _DISM_UnmountImage($sMountPath, $iFlags = $DISM_DISCARD_IMAGE, $hCancelEvent = 0, $pProgress = DllCallbackGetPtr($DISM_PROGRESS_CALLBACK), $vUserData = 0) Local $aResult = DllCall($ghdismapi, "LONG", "DismUnmountImage", _ "WSTR", $sMountPath, _ "DWORD", $iFlags, _ "PTR", $hCancelEvent, _ "PTR", $pProgress, _ "PTR", $vUserData _ ) If @error Then Return SetError(@error, 0, "DismUnmountImage") If $aResult[0] < 0 Then Return SetError($aResult[0], _WinAPI_GetLastError(), $aResult[0]) Return SetExtended(_WinAPI_GetLastError(), $aResult[0]) EndFunc ;==>_DISM_UnmountImage ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetErrorMesageText ; Description ...: Converts an Error Code to its Message Text ; Syntax.........: _DISM_GetErrorMesageText($iErrorCode) ; Parameters.....: $iErrorCode - Specifies the error code thrown by DISM function. ; | C0040001 - $DISMAPI_E_DISMAPI_NOT_INITIALIZED ; | C0040002 - $DISMAPI_E_SHUTDOWN_IN_PROGRESS ; | C0040003 - $DISMAPI_E_OPEN_SESSION_HANDLES ; | C0040004 - $DISMAPI_E_INVALID_DISM_SESSION ; | C0040005 - $DISMAPI_E_INVALID_IMAGE_INDEX ; | C0040006 - $DISMAPI_E_INVALID_IMAGE_NAME ; | C0040007 - $DISMAPI_E_UNABLE_TO_UNMOUNT_IMAGE_PATH ; | C0040009 - $DISMAPI_E_LOGGING_DISABLED ; | C004000A - $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_UNMOUNT_IMAGE_PATH ; | C004000B - $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_MOUNT_IMAGE_PATH ; | C004000C - $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_REMOUNT_IMAGE_PATH ; | C004000D - $DISMAPI_E_PARENT_FEATURE_DISABLED ; | C004000E - $DISMAPI_E_MUST_SPECIFY_ONLINE_IMAGE ; | C1510114 - $DISMAPI_E_NEEDS_REMOUNT ; | 800f080c - $DISMAPI_E_UNKNOWN_FEATURE ; | 800f0902 - $DISMAPI_E_BUSY ; | 80070002 - $DISMAPI_E_FILE_NOT_FOUND ; | 80070057 - $DISMAPI_E_INVALIDARG ; | 800F0805 - $CBS_E_INVALID_PACKAGE ; | 800F0825 - $CBS_E_CANNOT_UNINSTALL ; | 80070003 - $DISMAPI_E_INVALID_MOUNT_PATH ; | C1420117 - $DISMAPI_E_UNABLE_TO_UNMOUNT_IMAGE_PROPERLY ; | C1420127 - $DISMAPI_E_UNABLE_TO_OPEN_IMAGE_PATH ; | 800f0830 - $CBS_E_IMAGE_UNSERVICEABLE ; | 80073713 - $ERROR_ADVANCED_INSTALLER_FAILED ; | c004000d - $ERROR_ENABLE_DISABLE_FEATURE_INTERNAL_EXECUTION_FAIL ; | c1420124 - $ERROR_DISM_REMOUNT_INTERNAL_EXECUTION_FAIL ; | c1510114 - $ERROR_DISM_CREATE_IMAGE_SESSION_INTERNAL_EXECUTION_FAIL ; Return values..: Success - Returns $error ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetLastErrorMessage ; ; =============================================================================================================================== Func _DISM_GetErrorMessageText($iErrorCode) Switch $iErrorCode Case $DISM_S_OK $iErrorCode = "Success." Case $DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED $iErrorCode = "The DISM session needs to be reloaded." Case $DISMAPI_E_DISMAPI_NOT_INITIALIZED $iErrorCode = "DISM API was not initialized for this process." Case $DISMAPI_E_SHUTDOWN_IN_PROGRESS $iErrorCode = "A DismSession was being shutdown when another operation was called on it." Case $DISMAPI_E_OPEN_SESSION_HANDLES $iErrorCode = "A DismShutdown was called while there were open DismSession handles." Case $DISMAPI_E_INVALID_DISM_SESSION $iErrorCode = "An invalid DismSession handle was passed into a DISMAPI function." Case $DISMAPI_E_INVALID_IMAGE_INDEX $iErrorCode = "An invalid image index was specified." Case $DISMAPI_E_INVALID_IMAGE_NAME $iErrorCode = "An invalid image name was specified." Case $DISMAPI_E_UNABLE_TO_UNMOUNT_IMAGE_PATH $iErrorCode = "An image that is not a mounted WIM or mounted VHD was attempted to be unmounted." Case $DISMAPI_E_LOGGING_DISABLED $iErrorCode = "Failed to gain access to the log file user specified." & @CRLF & _ "Logging has been disabled.." Case $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_UNMOUNT_IMAGE_PATH $iErrorCode = "A DismSession with open handles was attempted to be unmounted." Case $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_MOUNT_IMAGE_PATH $iErrorCode = "A DismSession with open handles was attempted to be mounted." Case $DISMAPI_E_OPEN_HANDLES_UNABLE_TO_REMOUNT_IMAGE_PATH $iErrorCode = "A DismSession with open handles was attempted to be remounted." Case $DISMAPI_E_PARENT_FEATURE_DISABLED $iErrorCode = "One or several parent features are disabled so current feature can not be enabled." & @CRLF & _ "Solutions:" & @CRLF & _ "1. Call function DismGetFeatureParent to get all parent features and enable all of them. Or" & @CRLF & _ "2. Set EnableAll to TRUE when calling function DismEnableFeature." Case $DISMAPI_E_MUST_SPECIFY_ONLINE_IMAGE $iErrorCode = "The offline image specified is the running system." & @CRLF & _ "The macro DISM_ONLINE_IMAGE must be used instead." Case $DISMAPI_E_NEEDS_REMOUNT $iErrorCode = "The image needs to be remounted before any servicing operation." Case $DISMAPI_E_UNKNOWN_FEATURE $iErrorCode = "The feature is not present in the package." Case $DISMAPI_E_BUSY $iErrorCode = "The current package and feature servicing infrastructure is busy." & @CRLF & _ "Wait a bit and try the operation again." Case $DISMAPI_E_FILE_NOT_FOUND $iErrorCode = "File not found. Check if wim file or mount dir exist." Case $DISMAPI_E_INVALIDARG $iErrorCode = "One or more arguments are not valid:" & @CRLF & "e.g. any of the paths are not well-formed, does not exist or are invalid." & @CRLF & _ "Or the DismSession is invalid or not associated with a mounted image." Case $CBS_E_INVALID_PACKAGE $iErrorCode = "The current package is invalid." Case $CBS_E_CANNOT_UNINSTALL $iErrorCode = "Permanent package cannot be uninstalled." Case $DISMAPI_E_INVALID_MOUNT_PATH $iErrorCode = "The assigned mount path is not a valid WIM mount path." Case $DISMAPI_E_UNABLE_TO_UNMOUNT_IMAGE_PROPERLY $iErrorCode = "The directory could not be completely unmounted." Case $DISMAPI_E_UNABLE_TO_OPEN_IMAGE_PATH $iErrorCode = "Failed to gain access to the mount path." Case $CBS_E_IMAGE_UNSERVICEABLE $iErrorCode = "The image has been damaged by an offline servicing failure and no further servicing is allowed." & @CRLF & _ "The specified image is no longer serviceable." Case $ERROR_ADVANCED_INSTALLER_FAILED $iErrorCode = "Failed processing package changes with session options." Case $ERROR_ENABLE_DISABLE_FEATURE_INTERNAL_EXECUTION_FAIL $iErrorCode = "Failed to install one or more roles, role services, or features." & @CRLF & _ "One or more superior features are disabled relative to the current feature can not be activated." Case $ERROR_DISM_REMOUNT_INTERNAL_EXECUTION_FAIL $iErrorCode = "The specified directory could not be mounted, because the image has been changed in the wim file after deployment." Case $ERROR_DISM_CREATE_IMAGE_SESSION_INTERNAL_EXECUTION_FAIL $iErrorCode = "Could not create the image session. The specified image is not in a valid state, it must be redeployed." Case $ERROR_DISM_REQUEST_NOT_SUPPORTED $iErrorCode = "The request is not supported." & @CRLF & _ "The DISM log file can be found at " & $DISM_LOG_PATH & "." Case $ERROR_DISM_IMAGE_ALREADY_PROVIDED $iErrorCode = "The specified image was already provided." Case 0x8000000A $iErrorCode = "The specified image is in use." Case Else $iErrorCode = "Error Code Unknown: " & Hex($iErrorCode) & "." EndSwitch Return $iErrorCode EndFunc ;==>_DISM_GetErrorMesageText ; #FUNCTION# ==================================================================================================================== ; Name...........: DismErrorHandler ; Description ...: Enables a global dism error message modification. ; Syntax.........: DismErrorHandler($hWin) ; Parameters ....: $iErrorCode - Specifies the error code thrown by DISM function. ; $iFlag - The flag indicates the type of message box and the possible button combinations. See MsgBox(). ; $sTitle - The title of the message box. ; $sErrorType - The error type as string to use as initialization text. ; Return values .: ; Author(s) .....: André Cut ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ; =============================================================================================================================== Func _DISM_ErrorHandler($iErrorCode, $sErrorType) Local $sErrorMsg Local $hResult = _DISM_GetLastErrorMessage($sErrorMsg) If @error Then $hResult = _DISM_GetErrorMessageText($iErrorCode) Local $sLastError = "", $sDismError = "" Local $ret = DllCall("Kernel32.dll", "int", "GetLastError") _WinAPI_FormatMessage(0x00001000, 0, Hex($iErrorCode), 0, $sDismError, 4096, 0) _WinAPI_FormatMessage(0x00001000, 0, $ret[0], 0, $sLastError, 4096, 0) ;~ MsgBox($iFlag, $sTitle, $sErrorType & " error: " & $sErrorMsg & @CRLF & "ErrorCode: 0x" & Hex($iErrorCode) & @CRLF & "LastError: " & $sLastError & @CRLF & "Error Message of error code: " & $sDismError & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended) If Hex($iErrorCode) = $CBS_E_IMAGE_UNSERVICEABLE Then Exit Return $sErrorType & " error: " & $sErrorMsg & @CRLF & "ErrorCode: 0x" & Hex($iErrorCode) & @CRLF & "LastError: " & $sLastError & @CRLF & "Error Message of error code: " & $sDismError & @CRLF & "@error: " & @error & @CRLF & "@extended: " & @extended EndFunc ;==>_DISM_ErrorHandler ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetDriverSignature ; Description ...: Converts a DismDriverSignature Enumeration value to its constant name ; Syntax.........: _DISM_GetDriverSignature($DriverSignature) ; Parameters.....: $DriverSignature - Specifies the signature status of a driver. ; | 0 - $DismDriverSignatureUnknown ; | 1 - $DismDriverSignatureUnsigned ; | 2 - $DismDriverSignatureSigned ; Return values..: Success - Returns $DriverSignature ; | Unknown - The signature status of the driver is unknown. DISM only checks for a valid signature for boot-critical drivers. ; | Unsigned - The driver is unsigned. ; | Signed - The driver is signed. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetPackageFeatureState, _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetFullyOfflineInstallableType ; ; =============================================================================================================================== Func _DISM_GetDriverSignature($DriverSignature) Switch $DriverSignature Case $DismDriverSignatureUnknown $DriverSignature = "Unknown" Case $DismDriverSignatureUnsigned $DriverSignature = "Unsigned" Case $DismDriverSignatureSigned $DriverSignature = "Signed" EndSwitch Return $DriverSignature EndFunc ;==>_DISM_GetDriverSignature ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetFullyOfflineInstallableType ; Description ...: Converts a DismFullyOfflineInstallableType Enumeration value to its constant name ; Syntax.........: _DISM_GetFullyOfflineInstallableType($FullyOfflineInstallableType) ; Parameters.....: $FullyOfflineInstallableType - Specifies whether a package can be installed to an offline image without booting the image. ; | 0 - $DismFullyOfflineInstallable ; | 1 - $DismFullyOfflineNotInstallable ; | 2 - $DismFullyOfflineInstallableUndetermined ; Return values..: Success - Returns $FullyOfflineInstallableType ; | Installable - The package can be installed to an offline image without booting the image. ; | NotInstallable - You must boot into the image in order to complete installation of this package. ; | InstallableUndetermined - You may have to boot the image in order to complete the installation of this package. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetPackageFeatureState, _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetFullyOfflineInstallableType($FullyOfflineInstallableType) Switch $FullyOfflineInstallableType Case $DismFullyOfflineInstallable $FullyOfflineInstallableType = "Installable" Case $DismFullyOfflineNotInstallable $FullyOfflineInstallableType = "NotInstallable" Case $DismFullyOfflineInstallableUndetermined $FullyOfflineInstallableType = "InstallableUndetermined" EndSwitch Return $FullyOfflineInstallableType EndFunc ;==>_DISM_GetFullyOfflineInstallableType ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetImageBootable ; Description ...: Converts a DismImageBootable Enumeration value to its constant name ; Syntax.........: _DISM_GetImageBootable($ImageBootable) ; Parameters.....: $ImageBootable - Specifies the state of a package or a feature. ; | 0 - $DismImageBootableYes ; | 1 - $DismImageBootableNo ; | 2 - $DismImageBootableUnknown ; Return values..: Success - Returns $ImageBootable ; | Yes - The image is bootable. ; | No - The image is not bootable. ; | Unknown - The image type is unknown. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageType, _DISM_GetPackageFeatureState, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetImageBootable($ImageBootable) Switch $ImageBootable Case $DismImageBootableYes $ImageBootable = "Yes" Case $DismImageBootableNo $ImageBootable = "No" Case $DismImageBootableUnknown $ImageBootable = "Unknown" EndSwitch Return $ImageBootable EndFunc ;==>_DISM_GetImageBootable ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetImageType ; Description ...: Converts a DismImageType Enumeration value to its constant name ; Syntax.........: _DISM_GetImageType($ImageType) ; Parameters.....: $ImageType - Specifies the state of a package or a feature. ; | -1 - $DismImageTypeUnsupported ; | 0 - $DismImageTypeWim ; | 1 - $DismImageTypeVhd ; Return values..: Success - Returns $ImageType ; | Unsupported - The file type is unsupported. The image must be in a .wim, .vhd, or .vhdx file. ; | Wim - The image is in a .wim file. ; | Vhd - The image is in a .vhd or .vhdx file. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetPackageFeatureState, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetImageType($ImageType) Switch $ImageType Case $DismImageTypeUnsupported $ImageType = "Unsupported" Case $DismImageTypeWim $ImageType = "Wim" Case $DismImageTypeVhd $ImageType = "Vhd" EndSwitch Return $ImageType EndFunc ;==>_DISM_GetImageType ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetMountMode ; Description ...: Converts a DismMountMode Enumeration value to its constant name ; Syntax.........: _DISM_GetMountMode($MountMode) ; Parameters.....: $MountMode - Specifies the state of a package or a feature. ; | 0 - $DismReadWrite ; | 1 - $DismReadOnly ; Return values..: Success - Returns $MountMode ; | R/W - Mounts an image in read-write mode. ; | R - Mounts an image in read-only mode. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetPackageFeatureState, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetMountMode($MountMode) Switch $MountMode Case $DismReadWrite $MountMode = "R/W" Case $DismReadOnly $MountMode = "R" EndSwitch Return $MountMode EndFunc ;==>_DISM_GetMountMode ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetMountStatus ; Description ...: Converts a DismMountStatus Enumeration value to its constant name ; Syntax.........: _DISM_GetMountStatus($MountStatus) ; Parameters.....: $MountStatus - Specifies the state of a package or a feature. ; | 0 - $DismMountStatusOk ; | 1 - $DismMountStatusNeedsRemount ; | 2 - $DismMountStatusInvalid ; Return values..: Success - Returns $MountStatus ; | OK - Indicates that the mounted image is mounted and ready for servicing. ; | NeedsRemount - Indicates that the mounted image needs to be remounted before being serviced. ; | Invalid - Indicates that the mounted image is corrupt and is in an invalid state. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetPackageFeatureState, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetMountStatus($MountStatus) Switch $MountStatus Case $DismMountStatusOk $MountStatus = "Ok" Case $DismMountStatusNeedsRemount $MountStatus = "NeedsRemount" Case $DismMountStatusInvalid $MountStatus = "Invalid" EndSwitch Return $MountStatus EndFunc ;==>_DISM_GetMountStatus ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetPackageFeatureState ; Description ...: Converts a DismPackageFeatureState Enumeration value to its constant name ; Syntax.........: _DISM_GetPackageFeatureState($PackageState) ; Parameters.....: $PackageState - Specifies the state of a package or a feature. ; | 0 - $DismStateNotPresent ; | 1 - $DismStateUninstallPending ; | 2 - $DismStateStaged ; | 3 - $DismStateResolved ; | 3 - $DismStateRemoved ; | 4 - $DismStateInstalled ; | 5 - $DismStateInstallPending ; | 6 - $DismStateSuperseded ; | 7 - $DismStatePartiallyInstalled ; Return values..: Success - Returns $PackageState ; | NotPresent - The package or feature is not present. ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled. ; | Staged - The package or feature is staged. ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present. ; | Removed - Same as StateResolved ; | Installed - The package or feature is installed. ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed. ; | Superseded - The package or feature has been superseded by a more recent package or feature. ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetPackageFeatureState($PackageState) Switch $PackageState Case $DismStateNotPresent $PackageState = "NotPresent" Case $DismStateUninstallPending $PackageState = "UninstallPending" Case $DismStateStaged $PackageState = "Staged" Case $DismStateRemoved, $DismStateResolved $PackageState = "Resolved" Case $DismStateInstalled $PackageState = "Installed" Case $DismStateInstallPending $PackageState = "InstallPending" Case $DismStateSuperseded $PackageState = "Superseded" Case $DismStatePartiallyInstalled $PackageState = "PartiallyInstalled" EndSwitch Return $PackageState EndFunc ;==>_DISM_GetPackageFeatureState ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetReleaseType ; Description ...: Converts a DismPackageFeatureState Enumeration value to its constant name ; Syntax.........: _DISM_GetReleaseType($ReleaseType) ; Parameters.....: $ReleaseType - Specifies the release type of a package. ; | 0 - $DismReleaseTypeCriticalUpdate ; | 1 - $DismReleaseTypeDriver ; | 2 - $DismReleaseTypeFeaturePack ; | 3 - $DismReleaseTypeHotfix ; | 4 - $DismReleaseTypeSecurityUpdate ; | 5 - $DismReleaseTypeSoftwareUpdate ; | 6 - $DismReleaseTypeUpdate ; | 7 - $DismReleaseTypeUpdateRollup ; | 8 - $DismReleaseTypeLanguagePack ; | 9 - $DismReleaseTypeFoundation ; | 10 - $DismReleaseTypeServicePack ; | 11 - $DismReleaseTypeProduct ; | 12 - $DismReleaseTypeLocalPack ; | 13 - $DismReleaseTypeOther ; Return values..: Success - Returns $ReleaseType ; | CriticalUpdate - The package is a critical update. ; | Driver - The package is a driver. ; | FeaturePack - The package is a feature pack. ; | Hotfix - The package is a hotfix. ; | SecurityUpdate - The package is a security update. ; | SoftwareUpdate - The package is a software update. ; | Update - The package is a general update. ; | UpdateRollup - The package is an update rollup. ; | LanguagePack - The package is a language pack. ; | Foundation - The package is a foundation package. ; | ServicePack - The package is a service pack. ; | Product - The package is a product release. ; | LocalPack - The package is a local pack. ; | Other - The package is another type of release. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetPackageFeatureState, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetReleaseType($ReleaseType) Switch $ReleaseType Case $DismReleaseTypeCriticalUpdate $ReleaseType = "CriticalUpdate" Case $DismReleaseTypeDriver $ReleaseType = "Driver" Case $DismReleaseTypeFeaturePack $ReleaseType = "FeaturePack" Case $DismReleaseTypeHotfix $ReleaseType = "HotFix" Case $DismReleaseTypeSecurityUpdate $ReleaseType = "SecurityUpdate" Case $DismReleaseTypeSoftwareUpdate $ReleaseType = "SoftwareUpdate" Case $DismReleaseTypeUpdate $ReleaseType = "Update" Case $DismReleaseTypeUpdateRollup $ReleaseType = "UpdateRollup" Case $DismReleaseTypeLanguagePack $ReleaseType = "LanguagePack" Case $DismReleaseTypeFoundation $ReleaseType = "Foundation" Case $DismReleaseTypeServicePack $ReleaseType = "ServicePack" Case $DismReleaseTypeProduct $ReleaseType = "Product" Case $DismReleaseTypeLocalPack $ReleaseType = "LocalPack" Case $DismReleaseTypeOther $ReleaseType = "Other" EndSwitch Return $ReleaseType EndFunc ;==>_DISM_GetReleaseType ; #FUNCTION# ==================================================================================================================== ; Name...........: _DISM_GetRestartType ; Description ...: Converts a DismRestartType Enumeration value to its constant name ; Syntax.........: _DISM_GetRestartType($RestartType) ; Parameters.....: $RestartType - Specifies whether a restart is required after enabling a feature or installing a package. ; | 0 - $DismRestartNo ; | 1 - $DismRestartPossible ; | 2 - $DismRestartRequired ; Return values..: Success - Returns $RestartType ; | No - No restart is required. ; | Possible - This package or feature might require a restart. ; | Required - This package or feature always requires a restart. ; Failure - Not implemented ; Author(s)......: André Cut ; Modified.......: ; Remarks........: ; Related........: _DISM_GetPackageFeatureState, _DISM_GetReleaseType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType, _DISM_GetDriverSignature ; ; =============================================================================================================================== Func _DISM_GetRestartType($RestartType) Switch $RestartType Case $DismRestartNo $RestartType = "No" Case $DismRestartPossible $RestartType = "Possible" Case $DismRestartRequired $RestartType = "Required" EndSwitch Return $RestartType EndFunc ;==>_DISM_GetRestartType