Browse Source

Переделано под новые реалии сборки

master
paravis 2 years ago
parent
commit
c41f34cec1
  1. 333
      setup.au3

333
setup.au3

@ -1,232 +1,121 @@
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3> #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3> #include <GuiConstants.au3>
#include <WinAPI.au3> #include <file.au3>
#NoTrayIcon #NoTrayIcon
#RequireAdmin
Global $aArray = DriveGetDrive($DT_ALL), $sDisk, $iBtn11, $iBtn10, $iBtn7, $PathEr, $sDisk, $sDiskS, $UN11, $UN10x64, $UN10x86, $UN7x64, $UN7x86
#pragma compile(Stripper, True)
For $i = 1 To $aArray[0] #pragma compile(ProductVersion, 3.0.0)
$aFileList = _FileListToArrayRec($aArray[$i] & "\WindowsESD", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) #pragma compile(ProductName, "Change bootLoader")
If Not @error Then #pragma compile(FileDescription, CBL)
$sDisk = $aArray[$i] & "\WindowsESD\" #pragma compile(LegalCopyright, paravis.ru@2023)
$PathEr = 1 #pragma compile(CompanyName, paravis.ru@2023)
ExitLoop
EndIf Opt("ExpandEnvStrings", 1)
Next
$sDisk = StringLeft(@ScriptDir, 2)
For $i = 1 To $aArray[0] $boot = ($sDisk & "efi\Paravis\Boot")
$aFileList = _FileListToArrayRec($aArray[$i] & "\efi\Paravis\Windows", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) $kitchen = ($sDisk & "efi\Paravis\Boot\kitchen")
If Not @error Then $bootice = ($sDisk & "efi\Paravis\Boot\kitchen\bootice.exe")
$sDisk = $aArray[$i] & "\efi\Paravis\Windows\" $main = GUICreate("Change BootLoader", 390, 125, 318, 213)
$PathEr += 1 GUICtrlCreateGroup("Legacy BIOS", 3, 3, 384, 61)
ExitLoop GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
EndIf $xor = GUICtrlCreateButton("Install XorBoot", 8, 20, 121, 33)
Next GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$bmgr = GUICtrlCreateButton("Install Bootmgr", 134, 20, 121, 33)
If $PathEr > 1 Then GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
MsgBox(48, 'Предупреждение!', 'В системе больше одной папки с образами. Проверьте и удалите лишние (читаем ReadMe.txt). Система будет перезагружена.') $g4d = GUICtrlCreateButton("Install Grub4Dos", 261, 20, 121, 33)
Exit GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
EndIf GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("UEFI", 3, 62, 384, 61)
For $i = 1 To $aArray[0] GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$aFileList = _FileListToArrayRec($aArray[$i] & "\efi\Paravis\Boot\kitchen", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) $bmgru = GUICtrlCreateButton("Install Bootmgr (SecureBoot ON)", 8, 80, 180, 33)
If Not @error Then GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$sDiskS = $aArray[$i] & "\efi\Paravis\Boot\" $xoru = GUICtrlCreateButton("Install Xorboot (SecureBoot OFF)", 200, 80, 180, 33)
ExitLoop GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
EndIf GUISetState(@SW_SHOW, $main)
Next
Func _hide()
$ESD11 = $sDisk & "install_11.esd" GUICtrlSetState($xor, $gui_disable)
$ESD10x64 = $sDisk & "install_10_x64.esd" GUICtrlSetState($bmgr, $gui_disable)
$ESD10x86 = $sDisk & "install_10_x86.esd" GUICtrlSetState($g4d, $gui_disable)
$ESD7x64 = $sDisk & "install_7_x64.esd" GUICtrlSetState($bmgru, $gui_disable)
$ESD7x86 = $sDisk & "install_7_x86.esd" GUICtrlSetState($xoru, $gui_disable)
If FileExists ($sDisk & "autounattend\unattend11.xml") Then
$UN11 = " /unattend:" & $sDisk & "autounattend\unattend11.xml"
Else
$UN11 = ''
EndIf
If FileExists ($sDisk & "autounattend\unattend10x64.xml") Then
$UN10x64 = " /unattend:" & $sDisk & "autounattend\unattend10x64.xml"
Else
$UN10x64 = ''
EndIf
If FileExists ($sDisk & "autounattend\unattend10x86.xml") Then
$UN10x86 = " /unattend:" & $sDisk & "autounattend\unattend10x86.xml"
Else
$UN10x86 = ''
EndIf
If FileExists ($sDisk & "autounattend\unattend7x64.xml") Then
$UN7x64 = " /unattend:" & $sDisk & "autounattend\unattend7x64.xml"
Else
$UN7x64 = ''
EndIf
If FileExists ($sDisk & "autounattend\unattend7x86.xml") Then
$UN7x86 = " /unattend:" & $sDisk & "autounattend\unattend7x86.xml"
Else
$UN7x86 = ''
EndIf
$OEM11 = " /m:" & $sDisk & "$OEM11$"
$OEM10x64 = " /m:" & $sDisk & "$OEM10x64$"
$OEM10x86 = " /m:" & $sDisk & "$OEM10x86$"
$OEM7x64 = " /m:" & $sDisk & "$OEM7x64$"
$OEM7x86 = " /m:" & $sDisk & "$OEM7x86$"
$setup = "X:\sources\setup.exe /installfrom:"
If FileExists(@WindowsDir & "\SYSWOW64") Then
RunWait($sDiskS & "src_x64.exe auto2")
_x64()
Else
RunWait($sDiskS & "src_x86.exe auto2")
_x86()
EndIf
Func _x86()
$detect_efi = EnvGet("firmware_type")
If $detect_efi = "Legacy" Then
$hGUI = GUICreate("Windows Setup by Paravis", 410, 250, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
$font = "Segoe UI"
$iBtn10 = GUICtrlCreateButton("Установить Windows 10", 5, 5, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtn7 = GUICtrlCreateButton("Установить Windows 7", 5, 45, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnTC = GUICtrlCreateButton("Запустить Total Commander", 5, 105, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnR = GUICtrlCreateButton("Перезагрузка", 5, 145, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
GUISetState()
_checkesd86()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
;~ exit
Case $iBtn10
GUISetState(@SW_HIDE)
RunWait($setup & $ESD10x86 & $OEM10x86 & $UN10x86)
GUISetState(@SW_SHOW)
Case $iBtn7
GUISetState(@SW_HIDE)
RunWait($setup & $ESD7x86 & $OEM7x86 & $UN7x86)
GUISetState(@SW_SHOW)
Case $iBtnTC
GUISetState(@SW_HIDE)
RunWait($sDiskS & 'kitchen\TotalCommander\TOTALCMD.EXE /I="%%COMMANDER_PATH%%\tcmdmain.ini"')
GUISetState(@SW_SHOW)
Case $iBtnR
Exit
EndSwitch
WEnd
Else
If Not FileExists($sDisk & "install_10_x86.esd") Then
MsgBox(48, 'Предупреждение!', 'Не найден образ Windows 10 x86. Система будет перезагружена.')
Exit
EndIf
$hGUI = GUICreate("Windows Setup by Paravis", 360, 190, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
$font = "Segoe UI"
$iBtn10 = GUICtrlCreateButton("Установить Windows 10", 5, 5, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnTC = GUICtrlCreateButton("Запустить Total Commander", 5, 65, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnR = GUICtrlCreateButton("Перезагрузка", 5, 105, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
;~ exit
Case $iBtn10
GUISetState(@SW_HIDE)
RunWait($setup & $ESD10x86 & $OEM10x86 & $UN10x86)
GUISetState(@SW_SHOW)
Case $iBtnTC
GUISetState(@SW_HIDE)
RunWait($sDiskS & 'kitchen\TotalCommander\TOTALCMD.EXE /I="%%COMMANDER_PATH%%\tcmdmain.ini"')
GUISetState(@SW_SHOW)
Case $iBtnR
Exit
EndSwitch
WEnd
EndIf
EndFunc EndFunc
Func _x64() Func _show()
$hGUI = GUICreate("Windows Setup by Paravis", 410, 250, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUICtrlSetState($xor, $gui_enable)
GUISetBkColor(0xABCDEF) GUICtrlSetState($bmgr, $gui_enable)
GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState($g4d, $gui_enable)
GUISetState() GUICtrlSetState($bmgru, $gui_enable)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255) GUICtrlSetState($xoru, $gui_enable)
$font = "Segoe UI" EndFunc
$iBtn11 = GUICtrlCreateButton("Установить Windows 11", 5, 5, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtn10 = GUICtrlCreateButton("Установить Windows 10", 5, 45, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtn7 = GUICtrlCreateButton("Установить Windows 7", 5, 85, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnTC = GUICtrlCreateButton("Запустить Total Commander", 5, 145, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
$iBtnR = GUICtrlCreateButton("Перезагрузка", 5, 185, 350, 40)
GUICtrlSetFont(-1, 16, 500, 0, $font)
GUISetState()
_checkesd64()
While 1 While 1
Switch GUIGetMsg() Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE Case $gui_event_close
;~ exit ExitLoop
Case $iBtn11 Case $xor
GUISetState(@SW_HIDE) _hide()
RunWait($setup & $ESD11 & $OEM11 & $UN11) FileDelete($sDisk & "\bootmgr")
GUISetState(@SW_SHOW) FileDelete($sDisk & "\grldr")
Case $iBtn10 RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /restore /file=" & $boot & "\xor\xmbr.bin /keep_dpt /quiet")
GUISetState(@SW_HIDE) RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /restore /file=" & $boot & "\xor\xpbr.bin /keep_bpb /quiet")
RunWait($setup & $ESD10x64 & $OEM10x64 & $UN10x64) MsgBox(0 + 64 + 262144, "Xorboot", "bootloader successfully changed!")
GUISetState(@SW_SHOW) _show()
Case $iBtn7 Case $bmgr
GUISetState(@SW_HIDE) _hide()
RunWait($setup & $ESD7x64 & $OEM7x64 & $UN7x64) FileDelete(@ScriptDir & "Paravis")
GUISetState(@SW_SHOW) FileDelete($sDisk & "\bootmgr")
Case $iBtnTC FileDelete($sDisk & "\grldr")
GUISetState(@SW_HIDE) FileCopy($boot & "\mgr\bootmgr", $sDisk & "bootmgr")
RunWait($sDiskS & 'kitchen\TotalCommander\TOTALCMD64.EXE /I="%%COMMANDER_PATH%%\tcmdmain.ini"') RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=nt60 /quiet")
GUISetState(@SW_SHOW) RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=bootmgr /quiet")
Case $iBtnR MsgBox(0 + 64 + 262144, "Bootmgr", "bootloader successfully changed!")
Exit _show()
Case $g4d
_hide()
FileDelete($sDisk & "\bootmgr")
FileDelete($sDisk & "\grldr")
FileCopy($boot & "\g4d\grldr", $sDisk & "grldr")
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=GRUB4DOS /quiet")
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=GRUB4DOS /quiet")
MsgBox(0 + 64 + 262144, "Grub4Dos", "Bootloader successfully changed!")
_show()
Case $bmgru
_hide()
FileDelete($sDisk & "\efi\boot\bootx64.efi")
FileDelete($sDisk & "\efi\boot\bootia32.efi")
FileDelete($sDisk & "\efi\boot\bx86.pf")
FileDelete($sDisk & "\efi\boot\hx86.pf")
FileDelete($sDisk & "\efi\boot\x86.pf")
FileDelete($sDisk & "\efi\boot\bx64.pf")
FileDelete($sDisk & "\efi\boot\hx64.pf")
FileDelete($sDisk & "\efi\boot\x64.pf")
FileCopy($kitchen & "\UEFIx64\mgrx64.efi", $sDisk & "\efi\boot\bootx64.efi")
FileCopy($kitchen & "\UEFIx86\mgrx86.efi", $sDisk & "\efi\boot\bootia32.efi")
MsgBox(0 + 64 + 262144, "UEFI Bootmgr", "Bootloader successfully changed!")
_show()
Case $xoru
_hide()
FileDelete($sDisk & "\efi\boot\bootx64.efi")
FileDelete($sDisk & "\efi\boot\bootia32.efi")
FileDelete($sDisk & "\efi\boot\bx86.pf")
FileDelete($sDisk & "\efi\boot\hx86.pf")
FileDelete($sDisk & "\efi\boot\x86.pf")
FileDelete($sDisk & "\efi\boot\bx64.pf")
FileDelete($sDisk & "\efi\boot\hx64.pf")
FileDelete($sDisk & "\efi\boot\x64.pf")
FileCopy($kitchen & "\UEFIx64\bootx64.efi", $sDisk & "\efi\boot\bootx64.efi")
FileCopy($kitchen & "\UEFIx86\bootia32.efi", $sDisk & "\efi\boot\bootia32.efi")
FileCopy($kitchen & "\UEFIx86\bx86.pf", $sDisk & "\efi\boot\bx86.pf")
FileCopy($kitchen & "\UEFIx86\hx86.pf", $sDisk & "\efi\boot\hx86.pf")
FileCopy($kitchen & "\UEFIx86\x86.pf", $sDisk & "\efi\boot\x86.pf")
FileCopy($kitchen & "\UEFIx64\bx64.pf", $sDisk & "\efi\boot\bx64.pf")
FileCopy($kitchen & "\UEFIx64\hx64.pf", $sDisk & "\efi\boot\hx64.pf")
FileCopy($kitchen & "\UEFIx64\x64.pf", $sDisk & "\efi\boot\x64.pf")
MsgBox(0 + 64 + 262144, "UEFI Xorboot", "Bootloader successfully changed!")
_show()
EndSwitch EndSwitch
WEnd WEnd
EndFunc
Func _checkesd64()
If Not FileExists($sDisk & "install_11.esd") Then
GUICtrlSetState($iBtn11, $GUI_DISABLE)
EndIf
If Not FileExists($sDisk & "install_10_x64.esd") Then
GUICtrlSetState($iBtn10, $GUI_DISABLE)
EndIf
If Not FileExists($sDisk & "install_7_x64.esd") Then
GUICtrlSetState($iBtn7, $GUI_DISABLE)
EndIf
EndFunc
Func _checkesd86()
If Not FileExists($sDisk & "install_10_x86.esd") Then
GUICtrlSetState($iBtn10, $GUI_DISABLE)
EndIf
If Not FileExists($sDisk & "install_7_x86.esd") Then
GUICtrlSetState($iBtn7, $GUI_DISABLE)
EndIf
EndFunc
Loading…
Cancel
Save