Local $sWimFile = "C:\Anwendungsentwicklung\Unattended 10\sources\install_win7_x86.wim" Local $sMountPath = "C:\mount" Local $sLogFilePath = "C:\dism.log" Local $sScratchDirectory = "C:\scratchDir" #RequireAdmin #include "DISM.au3" #include #AutoIt3Wrapper_UseX64=y ; with this, autoit will break on line 1255 in DISM.au3 ;~ #include "_DLLStructDisplay.au3" ;~ $DISM_ERROR_TYPE = 0 ; 0 return text ; 1 return error code ; #VARIABLES# =================================================================================================================== ConsoleWrite("--------------------------------" & "DismInitialize" & @CRLF) ;~ ConsoleWrite("xdfsf") $init = _DISM_Initialize($DismLogErrorsWarningsInfo, $sLogFilePath) ;~ ConsoleWrite("DismInitialize error: " & Hex(@error) & @CRLF) ;~ ConsoleWrite("DismInitialize returns: " & _DISM_GetErrorMessageText($init) & @CRLF) ;~ _DISM_ErrorHandler($init, 16, "Fenster", "Adding Update") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismOpenSession" & @CRLF) ;~ Local $session ;~ $isession = _DISM_OpenSession($sMountPath, $session) ;~ If @error Then ConsoleWrite("$isessionerror: " & $isession & @CRLF) ;~ ConsoleWrite("DismOpenSession returns: " & _DISM_GetErrorMessageText($isession) & @CRLF) ;~ ConsoleWrite("Session: " & $session & @CRLF) ;~ _DISM_ErrorHandler($init, 16, "Fenster", "Adding Update") ; =============================================================================================================================== ;~ Local $test ;~ ConsoleWrite("--------------------------------" & "DismGetPackages" & @CRLF) ;~ $getpackage = _DismGetProvisionedAppxPackages($session, $test) ;~ ConsoleWrite("_DismGetProvisionedAppxPackages error: " & @error & @CRLF) ;~ ConsoleWrite("_DismGetProvisionedAppxPackages returns: " & $getpackage & @CRLF) ;~ _ArrayDisplay($getpackage, "GetPackages") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismMountImage" & @CRLF) ;~ $return = _DISM_MountImage($sWimFile, $sMountPath, 3, 0, $DismImageIndex, $DISM_MOUNT_READWRITE) ;~ ConsoleWrite("_DISM_MountImage error: " & @error & @CRLF) ;~ ConsoleWrite("_DISM_MountImage return: " & _DISM_GetErrorMessageText($return) & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismAddDriver" & @CRLF) ;~ $add = _DISM_AddDriver($session, "C:\HDx64\viahdb.inf", False) ;~ ConsoleWrite("DismAddDriver error: " & @error & @CRLF) ;~ ConsoleWrite("DismAddDriver returns: " & _DISM_GetErrorMessageText($add) & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismAddPackage" & @CRLF) ;~ $addpackage = _DISM_AddPackage($session, "C:\wichtig\w61-x64\glb\", True, False, 0, DllCallbackGetPtr($DISM_PROGRESS_CALLBACK)) ;~ ConsoleWrite("DismAddPackage error: " & @error & @CRLF) ;~ If $addpackage = 1 Then ;~ _DISM_CloseSession($session) ; close session ;~ $session = _DISM_OpenSession($sMountPath) ;~ ElseIf $addpackage < 0 Then ;~ FileWrite("c:\updatess.txt","fehler") ;~ _DISM_ErrorHandler($addpackage, 16, "Fenster", $addpackage) ;~ EndIf ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismApplyUnattend" & @CRLF) ;~ $apply = _DISM_ApplyUnattend($session, "C:\win7_unattended\AutoUnattend.xml") ;~ ConsoleWrite("DismApplyUnattend error: " & @error & @CRLF) ;~ ConsoleWrite("DismApplyUnattend returns: " & _DISM_GetErrorMessageText($apply) & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismCleanupMountpoints" & @CRLF) ;~ $cleanup = _DISM_CleanupMountpoints() ;~ ConsoleWrite("DismCleanupMountpoints error: " & @error & @CRLF) ;~ ConsoleWrite("DismCleanupMountpoints returns: " & _DISM_GetErrorMessageText($cleanup) & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismCommitImage" & @CRLF) ;~ $commit = _DISM_CommitImage($session) ;~ ConsoleWrite("DismCommitImage error: " & @error & @CRLF) ;~ ConsoleWrite("DismCommitImage returns: " & _DISM_GetErrorMessageText($commit) & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismDisableFeature" & @CRLF) ;~ $disable = _DISM_DisableFeature($session, "TelnetClient") ;~ ConsoleWrite("DismDisableFeature error: " & @error & @CRLF) ;~ ConsoleWrite("DismDisableFeature returns: " & _DISM_GetErrorMessageText($disable) & @CRLF) ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismEnableFeature" & @CRLF) ;~ $enable = _DISM_EnableFeature($session, "TelnetClient") ;~ ConsoleWrite("DismEnableFeature error: " & @error & @CRLF) ;~ ConsoleWrite("DismEnableFeature returns: " & $enable & @CRLF) ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetDriverInfo" & @CRLF) ;~ Local $DriverPackage ;~ $getdriverinfo = _DISM_GetDriverInfo($session, "wvmbushid.inf", $DriverPackage, True, 1) ;~ ConsoleWrite("DismGetDriverInfo error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetDriverInfo returns: " & _DISM_GetErrorMessageText($getdriverinfo) & @CRLF) ;~ _ArrayDisplay($DriverPackage, "DriverPackage (Extended)") ;~ _ArrayDisplay($getdriverinfo, "DriverInfo") ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetDrivers" & @CRLF) ;~ $getdriver = _DISM_GetDrivers($session, True, 1) ;~ ConsoleWrite("DismGetDrivers error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetDrivers returns: " & _DISM_GetErrorMessageText($getdriver) & @CRLF) ;~ _ArrayDisplay($getdriver) ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetFeatureInfo" & @CRLF) ;~ Local $CustomProperties ;~ $featureinfo = _DISM_GetFeatureInfo($session, "WindowsMediaPlayer", $CustomProperties, 0, 0, 1) ;~ ConsoleWrite("DismGetFeatureInfo error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetFeatureInfo returns: " & _DISM_GetErrorMessageText($featureinfo) & @CRLF) ;~ _ArrayDisplay($featureinfo, "FeatureInfo") ;~ _ArrayDisplay($CustomProperties, "CustomProperties") ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetFeatureParent" & @CRLF) ;~ $featureparent = _DISM_GetFeatureParent($session, "WindowsMediaPlayer", 0, 0, 1) ;~ ConsoleWrite("DismGetFeatureParent error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetFeatureParent returns: " & _DISM_GetErrorMessageText($featureparent) & @CRLF) ;~ _ArrayDisplay($featureparent, "FeatureParent") ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetFeatures" & @CRLF) ;~ $getf = _DISM_GetFeatures($session) ;~ ConsoleWrite("DismGetFeatures error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetFeatures returns: " & _DISM_GetErrorMessageText($getf) & @CRLF) ;~ _ArrayDisplay($getf, "Features") ;~ ; =============================================================================================================================== ConsoleWrite("--------------------------------" & "DismGetImageInfo" & @CRLF) Local $info $imageinfo = _DISM_GetImageInfo($sWimFile, $info) ConsoleWrite("DismGetImageInfo error: " & @error & @CRLF) ConsoleWrite("DismGetImageInfo returns: " & _DISM_GetErrorMessageText($imageinfo) & @CRLF) _ArrayDisplay($imageinfo, "ImageInfo") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetMountedImageInfo" & @CRLF) ;~ $mountedimages = _DISM_GetMountedImageInfo(1) ;~ ConsoleWrite("_DISM_GetMountedImageInfo error: " & @error & @CRLF) ;~ ConsoleWrite("_DISM_GetMountedImageInfo return: " & $mountedimages & @CRLF) ;~ _ArrayDisplay($mountedimages, "MountedImageInfo") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetPackageInfo" & @CRLF) ;~ Local $CustomProperties ;~ Local $Features ;~ $packageinfo = _DISM_GetPackageInfo($session, "Microsoft-Windows-Client-Refresh-LanguagePack-Package~31bf3856ad364e35~amd64~de-DE~6.1.7601.17514", $CustomProperties, $Features, $DismPackageName, 1) ;~ ConsoleWrite("DismGetPackageInfo error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetPackageInfo returns: " & $packageinfo & @CRLF) ;~ _ArrayDisplay($CustomProperties, "CustomProperties") ;~ _ArrayDisplay($Features, "Features") ;~ _ArrayDisplay($packageinfo, "PackageInfo") ;~ ConsoleWrite($packageinfo & " " & VarGetType($packageinfo)) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismGetPackages" & @CRLF) ;~ $getpackage = _DISM_GetPackages($session, 1) ;~ ConsoleWrite("DismGetPackages error: " & @error & @CRLF) ;~ ConsoleWrite("DismGetPackages returns: " & $getpackage & @CRLF) ;~ _ArrayDisplay($getpackage, "GetPackages") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismRemountImage" & @CRLF) ;~ $remount = _DISM_RemountImage($sMountPath) ;~ ConsoleWrite("DismRemountImage error: " & @error & @CRLF) ;~ ConsoleWrite("DismRemountImage returns: " & $remount & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismRemoveDriver" & @CRLF) ;~ $remove = _DISM_RemoveDriver($session, "oem1.inf") ;~ ConsoleWrite("DismRemoveDriver error: " & @error & @CRLF) ;~ ConsoleWrite("DismRemoveDriver returns: " & $remove & @CRLF) ;~ ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismRemovePackage" & @CRLF) ;~ $removepackage = _DISM_RemovePackage($session, "Package_for_KB2446710~31bf3856ad364e35~amd64~~6.1.1.3") ;~ ConsoleWrite("DismRemovePackage error: " & @error & @CRLF) ;~ ConsoleWrite("DismRemovePackage returns: " & $removepackage & @CRLF) ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismCloseSession" & @CRLF) ;~ $close = _DISM_CloseSession($session) ;~ ConsoleWrite("DismCloseSession error: " & @error & @CRLF) ;~ ConsoleWrite("DismCloseSession returns: " & $close & @CRLF) ;~ _DISM_ErrorHandler($close, 16, "Fenster", "Close") ; =============================================================================================================================== ;~ ConsoleWrite("--------------------------------" & "DismUnmountImage" & @CRLF) ;~ $unmount = _DISM_UnmountImage($sMountPath, $DISM_DISCARD_IMAGE) ;~ ConsoleWrite("DismUnmountImage error: " & @error & @CRLF) ;~ ConsoleWrite("DismUnmountImage returns: " & $unmount & @CRLF) ; =============================================================================================================================== ConsoleWrite("--------------------------------" & "DismShutdown" & @CRLF) $shut = _DISM_Shutdown() ConsoleWrite("DismShutdown error: " & @error & @CRLF) ;~ ConsoleWrite("DismShutdown returns: " & $shut & @CRLF) ;~ _DISM_ErrorHandler($shut, 16, "Fenster", "$shut") ; =============================================================================================================================== Func CallBack($Current, $Total, $unused) Local $Percent = $Current*(100/$Total) If $Current > $Total Then FileWrite("c:\test.txt", "error") ;ConsoleWrite("error" & @CRLF) ;~ ConsoleWrite("Percent: " & $Percent & " cur: " & $Current & " total: " & $Total & @CRLF) Sleep(100) ; wait 100ms ProgressSet($Percent, StringFormat('%3i%% completed.', $Percent), "Adding") EndFunc Func _ArrayListDisplay(ByRef $ArrayList) Local $Opt = Opt("GUIOnEventMode", 0) Local $GUI = GUICreate("ArrayList", 572, 536) Local $ListView = GUICtrlCreateListView("Element|Wert", 8, 8, 553, 481) Local $Button = GUICtrlCreateButton("O.k.", 208, 496, 121, 33, 0) Local $counter = 1 For $e In $ArrayList GUICtrlCreateListViewItem($counter & '|' & $e, $ListView) $counter += 1 Next GUISetState(@SW_SHOW) Do Switch GUIGetMsg() Case -3 ExitLoop Case $Button ExitLoop EndSwitch Until 0 GUIDelete($GUI) Opt("GUIOnEventMode", $Opt) EndFunc