Browse Source

Изменил(а) на 'setup.au3'

master
paravis 2 years ago
parent
commit
f378b3e034
  1. 337
      setup.au3

337
setup.au3

@ -1,121 +1,232 @@
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3> #include <GUIConstantsEx.au3>
#include <GuiConstants.au3> #include <WindowsConstants.au3>
#include <file.au3> #include <WinAPI.au3>
#NoTrayIcon #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)
EndFunc
Func _show() Global $aArray = DriveGetDrive($DT_ALL), $sDisk, $iBtn11, $iBtn10, $iBtn7, $PathEr, $sDisk, $sDiskS, $UN11, $UN10x64, $UN10x86, $UN7x64, $UN7x86
GUICtrlSetState($xor, $gui_enable)
GUICtrlSetState($bmgr, $gui_enable) For $i = 1 To $aArray[0]
GUICtrlSetState($g4d, $gui_enable) $aFileList = _FileListToArrayRec($aArray[$i] & "\WindowsESD", "NOT.DEL", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
GUICtrlSetState($bmgru, $gui_enable) If Not @error Then
GUICtrlSetState($xoru, $gui_enable) $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 EndFunc
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 While 1
Switch GUIGetMsg() Switch GUIGetMsg()
Case $gui_event_close Case $GUI_EVENT_CLOSE
ExitLoop ;~ exit
Case $xor Case $iBtn11
_hide() GUISetState(@SW_HIDE)
FileDelete($sDisk & "\bootmgr") RunWait($setup & $ESD11 & $OEM11 & $UN11)
FileDelete($sDisk & "\grldr") GUISetState(@SW_SHOW)
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /restore /file=" & $boot & "\xor\xmbr.bin /keep_dpt /quiet") Case $iBtn10
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /restore /file=" & $boot & "\xor\xpbr.bin /keep_bpb /quiet") GUISetState(@SW_HIDE)
MsgBox(0 + 64 + 262144, "Xorboot", "bootloader successfully changed!") RunWait($setup & $ESD10x64 & $OEM10x64 & $UN10x64)
_show() GUISetState(@SW_SHOW)
Case $bmgr Case $iBtn7
_hide() GUISetState(@SW_HIDE)
FileDelete(@ScriptDir & "Paravis") RunWait($setup & $ESD7x64 & $OEM7x64 & $UN7x64)
FileDelete($sDisk & "\bootmgr") GUISetState(@SW_SHOW)
FileDelete($sDisk & "\grldr") Case $iBtnTC
FileCopy($boot & "\mgr\bootmgr", $sDisk & "bootmgr") GUISetState(@SW_HIDE)
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=nt60 /quiet") RunWait($sDiskS & 'kitchen\TotalCommander\TOTALCMD64.EXE /I="%%COMMANDER_PATH%%\tcmdmain.ini"')
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=bootmgr /quiet") GUISetState(@SW_SHOW)
MsgBox(0 + 64 + 262144, "Bootmgr", "bootloader successfully changed!") Case $iBtnR
_show() Exit
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