w10install/source/installer.pb
Michael H.G. Schmidt 739f57e001 bugfix
2024-09-28 16:34:46 +02:00

147 lines
4.1 KiB
Plaintext

; installer.pb
; ------------------------------------------------------------
; installer wrapper for setup.exe
; LICENSE : GPL
; AUTHOR : Michael H.G. Schmidt
; EMAIL : michael@schmidt2.de
; DATE : 20240103
; ------------------------------------------------------------
;
; preparations to use native "system" command ...
ImportC "msvcrt.lib"
system(str.p-ascii)
EndImport
; Get system drive
Global SYS$=GetEnvironmentVariable("SystemDrive")
Procedure StartInstallation()
Result = MessageRequester("+++ Windows 10 unattended Installation +++",
"This will install a new OS (unattended)" + Chr(13) +
"and it will DELETE all DATA an your [ C: ] Drive!",
#PB_MessageRequester_YesNo | #PB_MessageRequester_Info)
If Result = #PB_MessageRequester_Yes
Result = MessageRequester("Caution !",
"LAST WARNING:" + Chr(13) +
"REALLY DELETE ALL Data on DRIVE [ C: ] ?",
#PB_MessageRequester_YesNo | #PB_MessageRequester_Warning)
If Result = #PB_MessageRequester_Yes
; kill main window ...
CloseWindow(0)
; format disk ...
dummy=system(SYS$ + "\windows\system32\cmd.exe /C " + SYS$ + "\format-disk.cmd")
; start installation ...
dummy=system(SYS$ + "\winsetup.exe /unattend:" + SYS$ + "\autounattend.xml")
End
EndIf
EndIf
; new fullscreen window with red colour ...
OpenWindow(10, 0, 0, 0, 0, "", #PB_Window_BorderLess | #PB_Window_Maximize)
SetWindowColor(10, RGB($FF,$00,$00))
; kill main window ...
CloseWindow(0)
MessageRequester("END.","Press OK to shutdown your system.",#PB_MessageRequester_Info)
End
EndProcedure
Procedure StartCMD()
MessageRequester("HELP. Please read me 1st.",
"Type <netuse> to mount a network share" + Chr(13) +
"Type <snapshot64> to start backup/restore" + Chr(13) + Chr(13) +
"(Network will be started automatically but it must" + Chr(13) +
" be connected with a cable and a DHCP server" + Chr(13) +
" must be present in your local network)",
#PB_MessageRequester_Info)
; start a command shell ...
dummy=system(SYS$ + "\windows\system32\cmd.exe /C start /D " + SYS$ + "\ " + SYS$ + "\windows\system32\cmd.exe /K wpeutil initializenetwork")
EndProcedure
Procedure StartSnapshot64()
; start backup/restore program ...
dummy=system(SYS$ + "\windows\system32\cmd.exe /C start /D " + SYS$ + "\ " + SYS$ + "\snapshot64.exe")
EndProcedure
; Button handler procedure
Procedure ButtonHandler()
Select EventGadget()
Case 0
StartInstallation()
Case 1
StartCMD()
Case 2
StartSnapshot64()
EndSelect
EndProcedure
;;;;;;;
; MAIN
;;;;;;;
; open window to hide all other windows on desktop ...
OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_BorderLess | #PB_Window_Maximize)
; set colour to windows blue ...
SetWindowColor(0, RGB($00,$a2,$ed))
; Get window size
W = WindowWidth(0)
H = WindowHeight(0)
; Shrink factor for buttons
S=0.1
; position calculations for the buttons
X0=W/2-(W*S/2)
GAP=W*0.01
ButtonW=W*0.1
ButtonH=H*0.1
BX0=X0 - (ButtonW*3 + GAP*2)/2
BX1=BX0 + ButtonW + GAP
BX2=BX1 + ButtonW + GAP
BY=H/2-ButtonH/2
; Create Buttons
ButtonGadget(0, BX0, BY, ButtonW, ButtonH, "INSTALL", #PB_Button_MultiLine)
BindGadgetEvent(0, @ButtonHandler())
ButtonGadget(1, BX1, BY, ButtonW, ButtonH, "Commandshell"+Chr(13)+"(with network)", #PB_Button_MultiLine)
BindGadgetEvent(1, @ButtonHandler())
ButtonGadget(2, BX2, BY, ButtonW, ButtonH, "Snapshot"+Chr(13)+"(Backup/Restore)", #PB_Button_MultiLine)
BindGadgetEvent(2, @ButtonHandler())
; MAIN LOOP
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; CursorPosition = 34
; FirstLine = 17
; Folding = -
; EnableXP