[Main]
Title=Driver Integration
Type=Plugin
Author=JFX, 2aCD, ChrisR
Description=Add Drivers to your Windows Vista or Windows 7/8/8.1/10 PE#$xDISM Export Driver feature requires Win8.1 or Win10 Host OS
Credits=http://TheOven.org
Version=028
Download_Level=0
Level=6
Selected=True
Mandatory=False
NoWarning=False
Contact=http://TheOven.org
Date=2017.01.10_16:23.01 (GMT0: -3 Hours)
Depend=
Disable=
Web1=http://w7pese.cwcodes.net/Projects/Win7PESE/Drivers/zz_Drivers.script
CertifidBy=
Certification=
HistoryNotes01=
History002=2aCD - add 'Allow unsigned Drivers'
History003=ChrisR - Check Drivers to integrate
History004=ChrisR - Adding the integration of driver with pause (checkbox)
History005=Amalux - get dism folder check
History005=Lancelot - ssshim.dll added to [Process_Vista_Check]
History006=ChrisR - Retrieve,FOLDERSIZE gives negative number when size is bigger than 2 GB in wb wb82, wb80rv3, wb77rc2 (workaround: If,%FolderSize%,Bigger,0 ==> If,Not,%FolderSize%,Equal,0). Reported by Aeolis
History007=ChrisR - Following AU3381 updated
History008=ChrisR - Code Cleanup
History009=ChrisR - Driver Integration for Windows 8 PE.
History010=ChrisR - Check Add Servicing.
History012=ChrisR - Win8 used wimgapi from ADK (not from Win8 source) in tools folder, copied in dism folder for possible use after building.
History013=ChrisR-JFX - Under XP,2k3 HostOS, Win8 dism searches mui files in MUI\LangID. Hiveunload at the end of Win8 process, the system hive is sometimes not properly unloaded by dism under XP,2k3.
History014=ChrisR - copy dism.exe.mui with en-US fallback
History015=ChrisR - Retrieve the errors number of the drivers integration in setupapi.offline.log and put an "echo warn" in case of failure
History016=ChrisR - Win8.1 Compatibility by using ADK for Win8 dism
History017=ChrisR - Typo System32\System32 on Install your Drivers link. Thanks Aeolis
History018=ChrisR - Adjust EFI BCD with TestSigning ON for running Unsigned Drivers with UEFI Firmware. SecureBoot should be turned OFF.
History019=kyhi - Added dism export host OS system 3rd party drivers Feature
History020=kyhi - Added double drivers open export folder
History021=ChrisR - Added double drives export host driver. Same code for x86/x64 Export_Drivers (direct or batch with pause). Check OSversion for Win8.1 dism export. cosmetic
History022=ChrisR - Win10 Compatibility
History023=Kyhi - Fixed driver hostOSversion check by using;; Call,HostOSVersion,,3
History024=ChrisR - Call,CompareVersions,%HostOSVersion3% following ML - 2015.08.25
History025=Lancelot - Added DU Buttons
History026=ChrisR - Implemented HostOSVersion - Date:2016.09.02
History027=JFX - Specify the log file location (target_win\Logs\DISM\Dism.log) and do not merged with the host OS one - Date:2016.09.24 - Date:2016.10.05
History028=ChrisR - Multi Fallback Languages support - Date:2016.11.23 - Date:2016.12.07 // Lancelot - Add Compare Button - Date:2017.01.10

[Variables]
%b32%=%BootSRC%\Windows\System32
%i32%=%InstallSRC%\Windows\System32
%t32%=%TargetDir%\Windows\System32
%bWow%=%BootSRC%\Windows\SysWow64
%iWow%=%InstallSRC%\Windows\SysWow64
%tWow%=%TargetDir%\Windows\SysWow64
%unsigned%=
%DriverFolder%=
%DismLogPath%=%target_win%\Logs\DISM\dism.log
%SW_HIDE%=
%ExpFldr%=%ExpFldrx86%
%ExpFldrx86%=%GlobalTemplates%\Drivers_Export_Dism_x86
%ExpFldrx64%=%GlobalTemplates%\Drivers_Export_Dism_x64
CopyDismMuiHost=Run,%ScriptFile%,PCopyDismMuiHost

[PCopyDismMuiHost]
// #1=Source Folder - #2=Target Folder
Loop,%ScriptFile%,PCopyDismMuiHost_Loop,1,%NbLang%,#1,#2

[PCopyDismMuiHost_Loop]
StrFormat,Split,%MuiLangAll%,|,#c,#9
If,ExistFile,#1\#9\dism.exe.mui,Begin
FileCopy,#1\#9\*,#2
Loop,BREAK
End

[Interface]
pTextLabel3="Note:  Driver Packages need to be decompressed (*.inf)#$x                                                    > Sub-Folders are allowed",1,1,9,3,320,27,8,Bold
pTextLabel1="x86 Drivers:",1,1,16,34,77,18,8,Bold
pFileBox86=%GlobalTemplates%\Drivers_x86\,1,13,9,49,370,20,dir
pButton1=,1,8,382,47,24,24,Process-OpenDriver_x86,opendir.bmp,False,_Process-OpenDriver_x86,False,_Process-OpenDriver_x86_,False
pTextLabel2="x64 Drivers:",1,1,16,73,77,18,8,Bold
pFileBox64=%GlobalTemplates%\Drivers_x64\,1,13,9,89,370,20,dir
pButton2=,1,8,382,86,24,24,Process-OpenDriver_x64,opendir.bmp,False,_Process-OpenDriver_x64,False,_Process-OpenDriver_x64_,False
pRadioGroup1="Integration process",1,14,9,113,198,54,"Show process","Hide process",0
pCheckBox_Pause="Pause when integrating",1,3,220,129,147,18,False
pBevel1=pBevel1,1,12,8,176,198,107
pCheckBox2="Startmenu Shortcut",1,3,15,180,131,18,False
pTextBox2="Start Menu folder:",1,0,31,216,168,21,"Driver Management"
pTextBox3="Shortcut name:",1,0,31,256,168,21,"Load Integrated drivers"
pCheckBox1=" Load Drivers at startup",1,3,220,154,139,16,False
pCheckBox3="Allow to install Unsigned Drivers",1,3,220,179,193,18,False
pCheckBox4="Enable TEST Mode for running Unsigned Drivers with UEFI",1,3,221,201,313,18,False
pTextLabel4=Note:,1,1,221,227,30,18,8,Bold
pTextLabel5="''SecureBoot'' should be turned OFF.",1,1,254,227,245,18,8,Normal
pTextLabel6="Even in TEST Mode drivers must have a test certificate before installation.#$xYou can add  your own unverified certificates with:",1,1,221,240,348,28,8,Normal
pWebLabel2="Driver Signature Enforcement Overrider ",1,10,221,267,231,18,http://www.ngohq.com/?page=dseo
pWebLabel1="Latest DriverPacks",1,10,382,114,104,18,http://driverpacks.net/driverpacks/latest
pBevel2=pBevel2,1,12,8,296,471,67
Button_Export_Drivers="Dism Export Host Drivers",1,8,13,301,200,24,Export_Drivers,_Export_Drivers_,False
Button_Open_Export_Driver=,1,8,215,301,24,24,Open_Export_Driver,opendir.bmp,False,_Open_Export_Driver,False,_Open_Export_Driver_,False
Button_Export_Drivers_DD="Double Driver Export Host Drivers",1,8,256,301,192,24,Export_Drivers_DD,_Export_Drivers_DD_,False
Button_Open_Export_Driver_DD=,1,8,448,301,24,24,Open_Export_Driver_DD,opendir.bmp,False,_Open_Export_Driver_DD,False,_Open_Export_Driver_DD_,False
pTextLabel7=Note:,1,1,17,331,30,18,8,Bold
pTextLabel8="Check INF Manufacturer OSVersion, Architecture before integrate host exported drivers.",1,1,48,331,430,18,8,Normal
pTextLabel9="It is also better to do some manually clean up to remove some drivers: display, audio, printer,...",1,1,17,345,461,18,8,Normal
WebLabel_Plugin="Plugin Page",1,10,338,4,55,18,http://TheOven.org/index.php?board=9
Button_Download=,1,8,403,21,24,24,DownloadXXX,DoubleJDesignRavenna3dArrowDown0016016.bmp,False,False,_DownloadXXX_,False,"__DOWNLOAD Plugin"
Button_Upload=,1,8,403,-1,24,24,UploadXXX,BokehliciaCaptivaSoftwareupload0016016.bmp,False,False,_UploadXXX_,False,"__UPLOAD Plugin (Admins Only)"
Button_CompareEdit=,1,8,426,-1,24,24,CompareEditXXX,AmperossQetto2Move0016016.bmp,False,False,_CompareEditXXX_,False,"__DOWNLOAD and Compare with an Editor"

[Process]
Run,%ScriptFile%,Check_DriverSize
If,Not,%DriverFolderSize%,Equal,0,Begin
//-
Call,HostOSVersion,,4x
// 2aCD - Allow unsigned Drivers
If,%pCheckBox3%,Equal,True,Set,%unsigned%,/forceUnsigned
If,%pRadioGroup1%,Equal,0,Set,%OpenHide%,Open
If,%pRadioGroup1%,Equal,0,Set,%SW_HIDE%,@SW_HIDE
If,%pRadioGroup1%,Equal,1,Set,%OpenHide%,Hide
AddVariables,%ProjectDir%\script.project,MuiLang
StrFormat,Split,%MuiLangAll%,|,0,%NbLang%
//-
If,Not,ExistDir,%target_win%\Logs\DISM,DirMake,%target_win%\Logs\DISM
If,%OS%%SourceArch%,Equal,Win10x86,Run,%ScriptFile%,Process_Win10x86
If,%OS%%SourceArch%,Equal,Win10x64,Run,%ScriptFile%,Process_Win10x64
If,%OS%%SourceArch%,Equal,Win8.1x86,Run,%ScriptFile%,Process_Win8.1x86
If,%OS%%SourceArch%,Equal,Win8.1x64,Run,%ScriptFile%,Process_Win8.1x64
If,%OS%%SourceArch%,Equal,Win8x86,Run,%ScriptFile%,Process_Win8x86
If,%OS%%SourceArch%,Equal,Win8x64,Run,%ScriptFile%,Process_Win8x64
If,%OS%%SourceArch%,Equal,Win7x86,Run,%ScriptFile%,Process_Win7x86
If,%OS%%SourceArch%,Equal,Win7x64,Run,%ScriptFile%,Process_Win7x64
If,%OS%%SourceArch%,Equal,WinVistax86,Run,%ScriptFile%,Process_Vistax86
If,%OS%%SourceArch%,Equal,WinVistax64,Run,%ScriptFile%,Process_Vistax64
Run,%ScriptFile%,CheckDriverIntFailure
//Enable TEST Mode for running Unsigned Drivers with UEFI
If,%pCheckBox3%%pCheckBox4%,Equal,TrueTrue,Run,%ScriptFile%,EfiBCDTestSigning
//-
// Load drivers at startup
If,%pCheckBox1%,Equal,True,Begin
If,ExistFile,%target_sys%\autorun.cmd,begin
TXTDelLine,%target_sys%\autorun.cmd,exit
TXTAddLine,%target_sys%\autorun.cmd,"PnpUtil.exe -i -a #$pSystemRoot#$p\inf\oem*.inf",Append
TXTAddLine,%target_sys%\autorun.cmd,exit,Append
End
End
If,%pCheckBox2%,Equal,true,Add_Shortcut,StartMenu,%pTextBox2%,#$pSystemRoot#$p\system32\cmd.exe,%pTextBox3%,#$pSystemRoot#$p\system32,"/c pnputil.exe -i -a #$pSystemRoot#$p\inf\oem*.inf","#$pSystemRoot#$p\system32\hdwwiz.exe",""
End

[Check_DriverSize]
Set,%DriverFolderSize%,0
If,%SourceArch%,Equal,x86,Set,%DriverFolder%,%pFileBox86%
If,%SourceArch%,Equal,x64,Set,%DriverFolder%,%pFileBox64%
If,ExistDir,%DriverFolder%,Begin
Retrieve,FOLDERSIZE,%DriverFolder%,%DriverFolderSize%
End

[Process_Vista_Check]
If,Not,ExistFile,%Tools%\zPeIMG.exe,Call,Echo,"Driver Integration requires zPeIMG.exe in folder %Tools%. Plugin Exit now",Warn,,MessageError,5,Exit
If,Not,ExistFile,%Tools%\peimg.exe,Call,Echo,"Driver Integration requires peimg.exe in folder %Tools%. Exit now",Warn,,MessageError,5,Exit
If,Not,ExistFile,%Tools%\ssshim.dll,Call,Echo,"Driver Integration (peimg.exe) requires ssshim.dll in folder %Tools%. Exit now",Warn,,MessageError,5,Exit

[Process_Vistax86]
Run,%scriptfile%,Process_Vista_Check
StrFormat,CTRIM,%pFileBox86%,\,%pFileBox86%
ShellExecute,%OpenHide%,%Tools%\%OSArch%\AU3381.exe,"#$q%Tools%\zPeIMG.exe#$q #$q%pFileBox86%#$q #$q%target_win%#$q %SW_HIDE%"

[Process_Vistax64]
Run,%scriptfile%,Process_Vista_Check
StrFormat,CTRIM,%pFileBox64%,\,%pFileBox64%
ShellExecute,%OpenHide%,%Tools%\%OSArch%\AU3381.exe,"#$q%Tools%\zPeIMG.exe#$q #$q%pFileBox64%#$q #$q%target_win%#$q %SW_HIDE%"

[Process_Win7x86]
StrFormat,CTRIM,%pFileBox86%,\,%pFileBox86%
Run,%ScriptFile%,CheckAdd-Servicing
Call,FileCopyMUI-Source,%b32%\dism.exe,%t32%\dism
If,Not,ExistFile,%t32%\dism\wdscore.dll,FileCopy,%b32%\wdscore.dll,%t32%\dism
If,Not,ExistFile,%t32%\dism\wimgapi.dll,FileCopy,%b32%\wimgapi.dll,%t32%\dism
Set,%targetdism%,%t32%\dism\dism.exe
Set,%WorkDir%,%t32%\dism
Set,%DriverDir%,%pFileBox86%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause

[Process_Win7x64]
StrFormat,CTRIM,%pFileBox64%,\,%pFileBox64%
Run,%ScriptFile%,CheckAdd-Servicing
Call,FileCopyMUI-Source,%b32%\dism.exe,%t32%\dism
If,Not,ExistFile,%t32%\dism\wdscore.dll,FileCopy,%b32%\wdscore.dll,%t32%\dism
If,Not,ExistFile,%t32%\dism\wimgapi.dll,FileCopy,%b32%\wimgapi.dll,%t32%\dism
Call,FileCopyMUI-Source,%iWow%\dism.exe,%tWow%\dism
If,Not,ExistFile,%tWow%\dism\wdscore.dll,FileCopy,%iWow%\wdscore.dll,%tWow%\dism
If,Not,ExistFile,%tWow%\dism\wimgapi.dll,FileCopy,%iWow%\wimgapi.dll,%tWow%\dism
If,%OSArch%,Equal,x86,Begin
Set,%targetdism%,%tWow%\dism\dism.exe
Set,%WorkDir%,%tWow%\dism
End
If,%OSArch%,Equal,x64,Begin
Set,%targetdism%,%t32%\dism\dism.exe
Set,%WorkDir%,%t32%\dism
End
Set,%DriverDir%,%pFileBox64%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause

[Process_Win8x86]
StrFormat,CTRIM,%pFileBox86%,\,%pFileBox86%
Run,%ScriptFile%,CheckAdd-Servicing
// Win8: used wimgapi from tools (ADK)
Call,FileCopyMUI-Source,%b32%\dism.exe,%t32%\dism
If,Not,ExistFile,%t32%\dism\wdscore.dll,FileCopy,%b32%\wdscore.dll,%t32%\dism
If,Not,ExistFile,%t32%\dism\wimgapi.dll,FileCopy,%tools%\x86\wimgapi.dll,%t32%\dism
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%XP2k3HostOS%,Equal,Yes,Begin
// Under XP it searches mui files in MUI\LangID
Call,HostOSLang
If,Not,ExistDir,%t32%\dism\MUI\%HostOSLang%,DirMake,%t32%\dism\MUI\%HostOSLang%
CopyDismMuiHost,%t32%\dism,%t32%\dism\MUI\%HostOSLang%
// Keep for a manual integration if needed
//DirDelete,%t32%\dism\%DistLang%
End
Set,%targetdism%,%t32%\dism\dism.exe
Set,%WorkDir%,%t32%\dism
Set,%DriverDir%,%pFileBox86%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Win8x64]
StrFormat,CTRIM,%pFileBox64%,\,%pFileBox64%
Run,%ScriptFile%,CheckAdd-Servicing
// Win8: used wimgapi from tools (ADK)
Call,FileCopyMUI-Source,%b32%\dism.exe,%t32%\dism
If,Not,ExistFile,%t32%\dism\wdscore.dll,FileCopy,%b32%\wdscore.dll,%t32%\dism
If,Not,ExistFile,%t32%\dism\wimgapi.dll,FileCopy,%tools%\x64\wimgapi.dll,%t32%\dism
Call,FileCopyMUI-Source,%iWow%\dism.exe,%tWow%\dism
If,Not,ExistFile,%tWow%\dism\wdscore.dll,FileCopy,%iWow%\wdscore.dll,%tWow%\dism
If,Not,ExistFile,%tWow%\dism\wimgapi.dll,FileCopy,%tools%\x86\wimgapi.dll,%tWow%\dism
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%OSArch%,Equal,x86,Begin
If,%XP2k3HostOS%,Equal,Yes,Begin
// Under XP it searches mui files in MUI\LangID
Call,HostOSLang
If,Not,ExistDir,%tWow%\dism\MUI\%HostOSLang%,DirMake,%tWow%\dism\MUI\%HostOSLang%
CopyDismMuiHost,%tWow%\dism,%tWow%\dism\MUI\%HostOSLang%
// Keep for a manual integration if needed
//DirDelete,%tWow%\dism\%DistLang%
End
Set,%targetdism%,%tWow%\dism\dism.exe
Set,%WorkDir%,%tWow%\dism
End
If,%OSArch%,Equal,x64,Begin
If,%XP2k3HostOS%,Equal,Yes,Begin
Call,HostOSLang
If,Not,ExistDir,%t32%\dism\MUI\%HostOSLang%,DirMake,%t32%\dism\MUI\%HostOSLang%
CopyDismMuiHost,%t32%\dism,%t32%\dism\MUI\%HostOSLang%
// Keep for a manual integration if needed
//DirDelete,%t32%\dism\%DistLang%
End
Set,%targetdism%,%t32%\dism\dism.exe
Set,%WorkDir%,%t32%\dism
End
Set,%DriverDir%,%pFileBox64%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Win8.1x86]
// Use ADK for Win8.1
If,Not,ExistFile,%Tools%\%SourceArch%\dism\dism.exe,Call,Echo,"dism.exe from ADK for Windows 8.1 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
Retrieve,FILEVERSION,%Tools%\%SourceArch%\dism\dism.exe,%dismexeVer%
If,%dismexeVer%,Smaller,6.3.9600.16384,Call,Echo,"dism.exe from ADK for Windows 8.1 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
// XP, 2k3, vista Not Compatible
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%HostOSVersion1%.%HostOSVersion2%,Equal,6.0,Set,%XP2k3HostOS%,Yes
If,%XP2k3HostOS%,Equal,Yes,Call,Echo,"Integration Driver for Win8.1 uses ADK for Win8.1, it is unfortunately not compatible with Windows XP, 2003 and Vista HostOS.#$x#$xExiting...",Warn,,MessageError,,Exit
//-
StrFormat,CTRIM,%pFileBox86%,\,%pFileBox86%
Run,%ScriptFile%,CheckAdd-Servicing
//-
Set,%targetdism%,%Tools%\%SourceArch%\dism\dism.exe
Set,%WorkDir%,%Tools%\%SourceArch%\dism
Set,%DriverDir%,%pFileBox86%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Win8.1x64]
// Use ADK for Win8.1
If,Not,ExistFile,%Tools%\%OSArch%\dism\dism.exe,Call,Echo,"dism.exe from ADK for Windows 8.1 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
If,%OSArch%,Equal,x86,Retrieve,FILEVERSION,%Tools%\x86\dism\dism.exe,%dismexeVer%
Else,Retrieve,FILEVERSION,%Tools%\x64\dism\dism.exe,%dismexeVer%
If,%dismexeVer%,Smaller,6.3.9600.16384,Call,Echo,"dism.exe from ADK for Windows 8.1 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
// XP, 2k3, vista Not Compatible
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%HostOSVersion1%.%HostOSVersion2%,Equal,6.0,Set,%XP2k3HostOS%,Yes
If,%XP2k3HostOS%,Equal,Yes,Call,Echo,"Integration Driver for Win8.1 uses ADK for Win8.1, it is unfortunately not compatible with Windows XP, 2003 and Vista HostOS.#$x#$xExiting...",Warn,,MessageError,,Exit
//-
StrFormat,CTRIM,%pFileBox64%,\,%pFileBox64%
Run,%ScriptFile%,CheckAdd-Servicing
//-
If,%OSArch%,Equal,x86,Begin
Set,%targetdism%,%Tools%\x86\dism\dism.exe
Set,%WorkDir%,%Tools%\x86\dism
End
If,%OSArch%,Equal,x64,Begin
Set,%targetdism%,%Tools%\x64\dism\dism.exe
Set,%WorkDir%,%Tools%\x64\dism
End
Set,%DriverDir%,%pFileBox64%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Win10x86]
// Use ADK for Win10
If,Not,ExistFile,%Tools%\%SourceArch%\dism\dism.exe,Call,Echo,"dism.exe from ADK for Windows 10 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
Retrieve,FILEVERSION,%Tools%\%SourceArch%\dism\dism.exe,%dismexeVer%
StrFormat,LEFT,%dismexeVer%,2,%MajdismexeVer%
If,%MajdismexeVer%,Smaller,10,Call,Echo,"dism.exe from ADK for Windows 10 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
// XP, 2k3, vista Not Compatible
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%HostOSVersion1%.%HostOSVersion2%,Equal,6.0,Set,%XP2k3HostOS%,Yes
If,%XP2k3HostOS%,Equal,Yes,Call,Echo,"Integration Driver for Win10 uses ADK for Win10, it is unfortunately not compatible with Windows XP, 2003 and Vista HostOS.#$x#$xExiting...",Warn,,MessageError,,Exit
//-
StrFormat,CTRIM,%pFileBox86%,\,%pFileBox86%
Run,%ScriptFile%,CheckAdd-Servicing
//-
Set,%targetdism%,%Tools%\%SourceArch%\dism\dism.exe
Set,%WorkDir%,%Tools%\%SourceArch%\dism
Set,%DriverDir%,%pFileBox86%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Win10x64]
// Use ADK for Win10
If,Not,ExistFile,%Tools%\%OSArch%\dism\dism.exe,Call,Echo,"dism.exe from ADK for Windows 10 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
If,%OSArch%,Equal,x86,Retrieve,FILEVERSION,%Tools%\x86\dism\dism.exe,%dismexeVer%
Else,Retrieve,FILEVERSION,%Tools%\x64\dism\dism.exe,%dismexeVer%
StrFormat,LEFT,%dismexeVer%,2,%MajdismexeVer%
If,%MajdismexeVer%,Smaller,10,Call,Echo,"dism.exe from ADK for Windows 10 is required for Driver Integration !!!#$xUse Retrieve Tools Plugin.#$x#$xExiting...",Warn,,MessageError,,Exit
// XP, 2k3, vista Not Compatible
Set,%XP2k3HostOS%,No
If,%HostOSVersion1%,Equal,5,Set,%XP2k3HostOS%,Yes
If,%HostOSVersion1%.%HostOSVersion2%,Equal,6.0,Set,%XP2k3HostOS%,Yes
If,%XP2k3HostOS%,Equal,Yes,Call,Echo,"Integration Driver for Win10 uses ADK for Win10, it is unfortunately not compatible with Windows XP, 2003 and Vista HostOS.#$x#$xExiting...",Warn,,MessageError,,Exit
//-
StrFormat,CTRIM,%pFileBox64%,\,%pFileBox64%
Run,%ScriptFile%,CheckAdd-Servicing
//-
If,%OSArch%,Equal,x86,Begin
Set,%targetdism%,%Tools%\x86\dism\dism.exe
Set,%WorkDir%,%Tools%\x86\dism
End
If,%OSArch%,Equal,x64,Begin
Set,%targetdism%,%Tools%\x64\dism\dism.exe
Set,%WorkDir%,%Tools%\x64\dism
End
Set,%DriverDir%,%pFileBox64%
//-
If,%pCheckBox_Pause%,Equal,False,ShellExecute,%OpenHide%,%targetdism%,"/image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",%WorkDir%
Else,Run,%ScriptFile%,Process_Pause
// In case sytem hive not unloaded by dism
If,ExistFile,%tools%\HiveUnload.exe,ShellExecute,Hide,%tools%\HiveUnload.exe,"/HKLM /Target:%target_sys%\config"

[Process_Pause]
Set,%w%,%projecttemp%\AddGetDrivers.cmd
If,ExistFile,%w%,ShellExecute,Hide,cmd.exe,"/C del /q /f #$q%w%#$q&del /q /f /A:R /A:H /A:S /A:A #$q%w%#$q"
If,ExistFile,%w%,Call,FileDelete,%w%
If,ExistFile,%w%,Call,Echo,"FILE %w% NOT DELETED",Warn,,MessageError,,Exit
FileCreateBlank,%w%
TXTAddLine,%w%,"@Echo Off",Append
TXTAddLine,%w%,"Echo=== Adds third-party driver packages ===",Append
TXTAddLine,%w%,"#$q%targetdism%#$q /image:#$q%TargetDir%#$q /Add-Driver /Driver:#$q%DriverDir%#$q /recurse %unsigned% /LogPath:#$q%DismLogPath%#$q",Append
TXTAddLine,%w%,"Echo.",Append
TXTAddLine,%w%,"Echo=== Listed third-party Divers ===",Append
TXTAddLine,%w%,"#$q%targetdism%#$q /image:#$q%TargetDir%#$q /Get-Drivers /Format:Table",Append
TXTAddLine,%w%,"Pause",Append
Shellexecute,Open,%w%,,%WorkDir%

[CheckAdd-Servicing]
//-- Servicing (DISM /PEIMG) required for drivers integration
If,Not,ExistDir,%target_win%\servicing,Begin
Echo,"Processing Servicing file copy..."
DirMake,%target_win%\servicing
FileCopy,%BootSRC%\Windows\servicing\*,%target_win%\servicing
End
If,Not,ExistDir,%t32%\dism,Begin
Echo,"Processing Dism file copy..."
DirMake,%t32%\dism
FileCopy,%b32%\dism\*,%t32%\dism
End
If,%SourceArch%,Equal,x64,If,Not,ExistDir,%tWow%\dism,Begin
Echo,"Processing WoW64 Dism file copy..."
DirMake,%tWow%\dism
FileCopy,%bWow%\dism\*,%tWow%\dism
End
If,Not,ExistDir,%t32%\SMI,Begin
Echo,"Processing SMI file copy..."
DirMake,%t32%\SMI
FileCopy,%b32%\SMI\*,%t32%\SMI
End

[CheckDriverIntFailure]
If,Not,ExistDir,%ProjectTemp%,DirMake,%ProjectTemp%
Set,%w%,%ProjectTemp%\DriverIntFailure.cmd
If,ExistFile,%w%,Shellexecute,Hide,cmd.exe,"/C del /q /f #$q%w%#$q"
If,ExistFile,%w%,Echo,"FILE %w% NOT DELETED",Warn
FileCreateBlank,%w%
TxtAddline,%w%,"@Echo off",Append
TxtAddline,%w%,"Cd /D #$q%target_win%\in f#$q",Append
TxtAddline,%w%,"Set _count=0",Append
TxtAddline,%w%,"For /f #$qtokens=3 delims= #$q #$p#$pj in ('find.exe /C #$q[Exit status: FAILURE#$q setupapi.offline.log') do (SET _count=#$p#$pj)",Append
TxtAddline,%w%,"Exit /b #$p_count#$p",Append
ShellExecute,Hide,%w%,,%ProjectTemp%
If,Not,%ExitCode%,Equal,0,Call,Echo,"Driver Integration. Exit status: %ExitCode% FAILURE(s) on setupapi.offline.log",Warn,5

[EfiBCDTestSigning]
If,ExistFile,%TargetDir%\efi\microsoft\boot\bcd,Begin
Run,%ScriptFile%,FindBCDedit
Echo,"Adjust UEFI BCD with TestSigning ON for running Unsigned Drivers with UEFI Firmware"
ShellExecute,Hide,%BcdEditExe%,"/store #$q%TargetDir%\efi\microsoft\boot\bcd#$q /set {default} TestSigning ON",%Tools%\%OSArch%\
End

[FindBCDedit]
If,Not,ExistFile,%Tools%\%SourceArch%\bcdedit.exe,FileCopy,%InstallSRC%\Windows\System32\bcdedit.exe,%Tools%\%SourceArch%
Set,%BcdEditExe%,%Tools%\%OSArch%\bcdedit.exe
If,Not,ExistFile,%BcdEditExe%,Set,%BcdEditExe%,%Tools%\x86\bcdedit.exe
//source x64 host x86
If,Not,ExistFile,%BcdEditExe%,Call,Echo,"%Tools%\%OSArch%\bcdedit.exe NOT found! Exit Now",Warn,,MessageError,,Exit

[Process-OpenDriver_x86]
Call,OpenDir,%pFileBox86%

[Process-OpenDriver_x64]
Call,OpenDir,%pFileBox64%

[Export_Drivers]
Run,%ScriptFile%,Check_Export_HostOSVersion
Call,HostOSArch
If,%HostOSArch%,Equal,x64,Set,%ExpFldr%,%ExpFldrx64%
//--
If,ExistDir,%ExpFldr%,Shellexecute,Hide,cmd.exe,"/C rd /s /q #$q%ExpFldr%#$q"
If,ExistDir,%ExpFldr%,Call,DirDelete,%ExpFldr%
DirMake,%ExpFldr%
Call,HostSystemDir
Set,%targetdism%,%HostSystemDir%\dism.exe
Set,%WorkDir%,%HostSystemDir%
//--
If,%pCheckBox_Pause%,Equal,True,Run,%ScriptFile%,Export_Drivers_Pause
Else,Begin
System,FILEREDIRECT,OFF
ShellExecute,Open,%targetdism%,"/online /Export-Driver /Destination:#$q%ExpFldr%#$q",%WorkDir%
System,FILEREDIRECT,ON
End

[Export_Drivers_Pause]
Set,%e%,%projecttemp%\ExportDrivers.cmd
If,ExistFile,%e%,ShellExecute,Hide,cmd.exe,"/C del /q /f #$q%e%#$q&del /q /f /A:R /A:H /A:S /A:A #$q%e%#$q"
If,ExistFile,%e%,Call,FileDelete,%e%
If,ExistFile,%e%,Call,Echo,"FILE %w% NOT DELETED",Warn,,MessageError,,Exit
FileCreateBlank,%e%
TXTAddLine,%e%,"@Echo Off",Append
TXTAddLine,%e%,"Echo=== Exporting Third-Party System Drivers ===",Append
TXTAddLine,%e%,"#$q%targetdism%#$q /online /Export-Driver /Destination:#$q%ExpFldr%#$q",Append
TXTAddLine,%e%,"Pause",Append
System,FILEREDIRECT,OFF
Shellexecute,Open,%e%,,%WorkDir%
System,FILEREDIRECT,ON

[Check_Export_HostOSVersion]
// Export driver only available on Windows 8.1 Update or windows 10
Call,HostSystemDir
If,Not,ExistFile,%HostSystemDir%\dism.exe,Call,Echo,"Host DISM Not Found",Warn,,MessageError,,Exit
//--
Call,HostOSVersion,,3
Call,CompareVersions,%HostOSVersion3%,9600
If,%CompareVersions%,Equal,Smaller,call,Echo,"A Windows 8.1 or Windows 10 Host PC is required to Export Drivers!!",Warn,,MessageError,,Exit

[Open_Export_Driver]
Call,HostOSArch
If,%HostOSArch%,Equal,x64,Set,%ExpFldr%,%ExpFldrx64%
Call,OpenDir,%ExpFldr%

[Export_Drivers_DD]
If,Not,ExistFile,%ProjectDir%\Drivers\Double Driver.Script,Call,Echo,"Double Driver Plugin required to Export Host drivers",Warn,,MessageError,,Exit
Run,%ProjectDir%\Drivers\Double Driver.Script,Called_Export_Driver,%ProjectDir%\Drivers\Double Driver.Script

[Open_Export_Driver_DD]
If,Not,ExistFile,%ProjectDir%\Drivers\Double Driver.Script,Call,Echo,"Double Driver Plugin required to Open exported Host drivers",Warn,,MessageError,,Exit
Run,%ProjectDir%\Drivers\Double Driver.Script,Called_Open_Export_Driver,%ProjectDir%\Drivers\Double Driver.Script

[AuthorEncoded]
Icon_3346.ico=4749,6332
Logo=Icon_3346.ico

[EncodedFile-AuthorEncoded-Icon_3346.ico]
lines=1
[encoded data, 6336 characters]

[InterfaceEncoded]
opendir.bmp=571,762
DoubleJDesignRavenna3dArrowDown0016016.bmp=622,830
BokehliciaCaptivaSoftwareupload0016016.bmp=676,902
AmperossQetto2Move0016016.bmp=893,1191

[EncodedFile-InterfaceEncoded-opendir.bmp]
lines=0
0=eJyVkt1LU3EYx382esMuBFEKE8GLLL0IbyYhpEUI4aKytilTFN1xOrvxohpI9/0FlYESXUR2EXmxi4S9hYF4IZhOSdZMzJdtx+HwvO1sh2/P8cyxYFh9+TzPxXm+v+9z+J1z847ZxA5lprpMVZarEnbeGNC8vNSoI+E/5Z6YZs++Mk+QPTnkaaiAo4ee0LVPEcN/4tViTRjuNB7Jeh/cAxfPcEnNtY8hAW4ZwwqGVbCxL3k/D5zxC71x9AjoTsGRgG0jbY2K1siBfV2ybyjd2xkHr7HHIcO/CZh8ApdEfwIDKXASnAr6BDh4dG5mbVHJui727ar0VuQ/924tCtyNoTwgGFQGdZyxrHMfLgUuFYMShg4wIOrhVTNb3zVYdtCbQD+vQ4sqQwKhH/cLFQGx1C+W+EQWlC/Nyw0LqRUVt7fQtZPDvgtrDB2JHD1JnJrl8/dpjqjLipb3P9zG/Ti+qQirWJY1Yi0L06pW6F+QtJZf+grCEkOYrus5q/iJ06tgiwoLZ+0v3vyRnwEdoailtG6ufllVN1FXO36x6Pcd8wYogXJOrqDsB66+rTdPtV7/aGmcar0weeX4f6N2srrpQ/ON6Xvt3i7q9e+bz74uvqVQt7wPOn0c9b86DbV9tjlnR6n/o39kzmNQdPoblHVTL3ic484vSM1LySzSS8otYBgFIw6YMUPoD4zY5WddWriPgQkAk7cIYWOapDwBAAAAAgAAACcAAADwAQAAAAAAAAEAAAAAAAAAAAAAAA

[DownloadXXX]
Call,DownloadXQ

[UploadXXX]
Call,UploadXMultiQ,,%ProjectDir%\Utils\WebRoots_SE.Script||WebRoot

[EncodedFile-InterfaceEncoded-DoubleJDesignRavenna3dArrowDown0016016.bmp]
lines=0
0=eJzNk09Ik2Ecxw06BF2KqG5ih1EgYZZu7+v7vnu3d++2MpelRFHgQZEaJLVIXSxrW4Wauf7Nwha2rQ7dOgT9IQT1EkQHi+hSHfRSUZrMcp389PjSoUib3vrB9/I8fD78fr+Hxwi0LS+yyi6ySWSVyGqRZUUl1rnr1/3vBfy3+TTxkabuAzx4dp+lsu/G31LRXIrjaCmeVjtfpj4v2jH+YQwpWIYc3orctgUptJkT/UcWxc/1rLXYqYpKqGcklEglcns5DuF48uLhPx2TUxOYIRWlU8PZraOdU1GjMsop4RO9+DucfM1NzuvIfctR3Wai9hq4rvrREybOCy608xpqrAqlQzhObiOSbv2Ln8nPsDvsZ33dSoob1mE7XIIsetAvCUePG63TiRpXUE47rJ0MvRz8wzH9fZqR0SHSj1LUhn2s8a6gMi7hTm7HddmLftHA2aVT2mJjY3Mx7naJ/I/8vHN0Zc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