diff --git a/setup.au3 b/setup.au3 index 40bd6dd..3ecb2f8 100644 --- a/setup.au3 +++ b/setup.au3 @@ -1,121 +1,232 @@ +#include +#include #include -#include -#include +#include +#include #NoTrayIcon -#RequireAdmin - -#pragma compile(Stripper, True) -#pragma compile(ProductVersion, 3.0.0) -#pragma compile(ProductName, "Change bootLoader") -#pragma compile(FileDescription, CBL) -#pragma compile(LegalCopyright, paravis.ru@2023) -#pragma compile(CompanyName, paravis.ru@2023) - -Opt("ExpandEnvStrings", 1) - -$sDisk = StringLeft(@ScriptDir, 2) -$boot = ($sDisk & "efi\Paravis\Boot") -$kitchen = ($sDisk & "efi\Paravis\Boot\kitchen") -$bootice = ($sDisk & "efi\Paravis\Boot\kitchen\bootice.exe") -$main = GUICreate("Change BootLoader", 390, 125, 318, 213) -GUICtrlCreateGroup("Legacy BIOS", 3, 3, 384, 61) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -$xor = GUICtrlCreateButton("Install XorBoot", 8, 20, 121, 33) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -$bmgr = GUICtrlCreateButton("Install Bootmgr", 134, 20, 121, 33) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -$g4d = GUICtrlCreateButton("Install Grub4Dos", 261, 20, 121, 33) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -GUICtrlCreateGroup("", -99, -99, 1, 1) -GUICtrlCreateGroup("UEFI", 3, 62, 384, 61) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -$bmgru = GUICtrlCreateButton("Install Bootmgr (SecureBoot ON)", 8, 80, 180, 33) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -$xoru = GUICtrlCreateButton("Install Xorboot (SecureBoot OFF)", 200, 80, 180, 33) -GUICtrlSetFont(-1, 8, 800, 0, "Tahoma") -GUISetState(@SW_SHOW, $main) - -Func _hide() - GUICtrlSetState($xor, $gui_disable) - GUICtrlSetState($bmgr, $gui_disable) - GUICtrlSetState($g4d, $gui_disable) - GUICtrlSetState($bmgru, $gui_disable) - GUICtrlSetState($xoru, $gui_disable) + +Global $aArray = DriveGetDrive($DT_ALL), $sDisk, $iBtn11, $iBtn10, $iBtn7, $PathEr, $sDisk, $sDiskS, $UN11, $UN10x64, $UN10x86, $UN7x64, $UN7x86 + +For $i = 1 To $aArray[0] + $aFileList = _FileListToArrayRec($aArray[$i] & "\WindowsESD", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) + If Not @error Then + $sDisk = $aArray[$i] & "\WindowsESD\" + $PathEr = 1 + ExitLoop + EndIf +Next + +For $i = 1 To $aArray[0] + $aFileList = _FileListToArrayRec($aArray[$i] & "\efi\Paravis\Windows", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) + If Not @error Then + $sDisk = $aArray[$i] & "\efi\Paravis\Windows\" + $PathEr += 1 + ExitLoop + EndIf +Next + +If $PathEr > 1 Then + MsgBox(48, 'Предупреждение!', 'В системе больше одной папки с образами. Проверьте и удалите лишние (читаем ReadMe.txt). Система будет перезагружена.') + Exit +EndIf + +For $i = 1 To $aArray[0] + $aFileList = _FileListToArrayRec($aArray[$i] & "\efi\Paravis\Boot\kitchen", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) + If Not @error Then + $sDiskS = $aArray[$i] & "\efi\Paravis\Boot\" + ExitLoop + EndIf +Next + +$ESD11 = $sDisk & "install_11.esd" +$ESD10x64 = $sDisk & "install_10_x64.esd" +$ESD10x86 = $sDisk & "install_10_x86.esd" +$ESD7x64 = $sDisk & "install_7_x64.esd" +$ESD7x86 = $sDisk & "install_7_x86.esd" +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 -Func _show() - GUICtrlSetState($xor, $gui_enable) - GUICtrlSetState($bmgr, $gui_enable) - GUICtrlSetState($g4d, $gui_enable) - GUICtrlSetState($bmgru, $gui_enable) - GUICtrlSetState($xoru, $gui_enable) +Func _x64() + $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" + $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 + Switch GUIGetMsg() + Case $GUI_EVENT_CLOSE +;~ exit + Case $iBtn11 + GUISetState(@SW_HIDE) + RunWait($setup & $ESD11 & $OEM11 & $UN11) + GUISetState(@SW_SHOW) + Case $iBtn10 + GUISetState(@SW_HIDE) + RunWait($setup & $ESD10x64 & $OEM10x64 & $UN10x64) + GUISetState(@SW_SHOW) + Case $iBtn7 + GUISetState(@SW_HIDE) + RunWait($setup & $ESD7x64 & $OEM7x64 & $UN7x64) + GUISetState(@SW_SHOW) + Case $iBtnTC + GUISetState(@SW_HIDE) + RunWait($sDiskS & 'kitchen\TotalCommander\TOTALCMD64.EXE /I="%%COMMANDER_PATH%%\tcmdmain.ini"') + GUISetState(@SW_SHOW) + Case $iBtnR + Exit + EndSwitch + 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 -While 1 - Switch GUIGetMsg() - Case $gui_event_close - ExitLoop - Case $xor - _hide() - FileDelete($sDisk & "\bootmgr") - FileDelete($sDisk & "\grldr") - RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /restore /file=" & $boot & "\xor\xmbr.bin /keep_dpt /quiet") - RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /restore /file=" & $boot & "\xor\xpbr.bin /keep_bpb /quiet") - MsgBox(0 + 64 + 262144, "Xorboot", "bootloader successfully changed!") - _show() - Case $bmgr - _hide() - FileDelete(@ScriptDir & "Paravis") - FileDelete($sDisk & "\bootmgr") - FileDelete($sDisk & "\grldr") - FileCopy($boot & "\mgr\bootmgr", $sDisk & "bootmgr") - RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=nt60 /quiet") - RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=bootmgr /quiet") - MsgBox(0 + 64 + 262144, "Bootmgr", "bootloader successfully changed!") - _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 -WEnd \ No newline at end of file +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 \ No newline at end of file