Leaderboard
Popular Content
Showing content with the highest reputation on 12/05/2021 in all areas
-
Study this one https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetOnEvent.htm You can put your gui in function a and by setting the events you can give each event a different function. This split will make your life easier in maintenance and shows clearly the intent of each action you want to do by splitting GUI from the actual functionality away. And if you really want to learn more there are offcourse many references on the internet but this is a nice list of some good practices https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29#file-clean_code-md1 point
-
Auto refresh label in GUI
Swe-Anders reacted to Subz for a topic
Updated the code above with comments, hope it makes sense. Basically AdlibRegister will run a function that you can use to check for changes every xxx ms (default 250 ms), once detected you can then update your label.1 point -
I just was editing my post with some rewritten code, see my previous post for some refactored code. "general rule of thumb" functions should not have more then 10-20 lines of code but split frequently and give your function a meaningfull name describing your intent. The more you do that the less comments you will need in your coding.1 point
-
AutoIt is a pretty lenient language compared to others, not that I have much experience with others but just from what I have read from other posts. In the future, you may want to learn another langauge so trying to incorporate best practice now could help later on. If a variable is modified from various points in the script, there isn't an issue with making it global but as was the case with $FIltered, does it need to be. Could it be local scope or passed ByRef. I have seen posts where people are having issues with code and they are expecting one value from a global variable but it is being changed elsewhere in a function as they have reused the variable name. When you create a variable it assigns a bit of memory to hold the value and though it's probably not an issue with todays ram sizes, but hogs memory if the variable isn't immediately required or may not be required when running the code. When your code gets more complex and too big for one file, you might start making UDFs of your own and keeping good structure and following naming conventions will make it easier when you come to troubleshoot issues. Have a peek inside the AutoIt UDFs and see how big things can get. When you declare variables outside of functions, AutoIt gives them a global scope. and some things benefit from this, liike a filepath. If you declare them inside functions using Local, the variable is destroyed when the function ends and the memory returned to the pool. If you had a massive array as global and this was only used in one function, it's a waste. I am sure others will add there knowledge about variables but a lot of times it's down to the individual and sometimes the size of the script whether its worth it. I try to give them scope and descriptive names as well as defining what value I am expecting on return. A read of the wiki will explain more in depth than I have.1 point
-
To get it to show initially you can run the _GetInfo function when you create the list. I commented the first run of _GetInfo out. Don't know if it is needed before the list control is created. I don't get the list clearing issues when I keep refreshing as I did previously. I only have one drive in this puter though. #NoTrayIcon #RequireAdmin #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ListBoxConstants.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> Global $DiskList, $RawList, $Array, $Selection, $MBR, $GPT, $Refresh, $bootDrive, $mainDrive _Cleanup() DirCreate(@WorkingDir & '\cache') $listFile = FileOpen(@WorkingDir & '\cache\list.ini', 2) FileWrite($listFile, 'lis dis') FileClose($listFile) ;~ _GetInfo() GUICreate('Prep/Format Disk v1.2', 300, 298) GUISetIcon(@WorkingDir & '\PrepareDiskNT.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('1: Select a disk to prepare for WinNTSetup5', 20, 10, 280) $DiskList = GUICtrlCreateList(_GetInfo(), 20, 30, 260, 150) $Refresh = GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('2: Select your desired layout...', 20, 214, 280, 30) $MBR = GUICtrlCreateButton('BIOS (MBR) Boot', 20, 232, 120, 40) $GPT = GUICtrlCreateButton('UEFI (GPT) Boot', 160, 232, 120, 40) GUICtrlCreateLabel('( * ) Disk is Currently GPT', 160, 278, 130, 30) GUISetState() Do $Selection = GUIGetMsg() If $Selection = $MBR Then Local $Disk = StringRegExpReplace(GUICtrlRead($DiskList), '(?i)^.*(Disk [\d]+).*$', '$1') Local $DiskN = StringSplit($Disk, "") Local $iMsgBoxAnswer If $Disk = "" Then MsgBox($MB_ICONERROR, "Notice: ", "No disk has been selected") Else $iMsgBoxAnswer = MsgBox(262452, 'This will FORMAT Disk ' & $DiskN[6], 'ALL DATA WILL BE ERASED FROM ' & 'DISK ' & $DiskN[6] & @CRLF & 'Are you sure you want to proceed?') Select Case $iMsgBoxAnswer = 6 ;Yes _FormatMBR($DiskN[6]) _IniWriteMBR() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $bootDrive) Run("cmd /c ..\WinNTSetup_x64.exe", @WorkingDir, @SW_HIDE) _Cleanup() Exit Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf EndIf If $Selection = $GPT Then Local $Disk = StringRegExpReplace(GUICtrlRead($DiskList), '(?i)^.*(Disk [\d]+).*$', '$1') Local $DiskN = StringSplit($Disk, "") Local $iMsgBoxAnswer If $Disk = "" Then MsgBox($MB_ICONERROR, "Notice: ", "No disk has been selected") Else $iMsgBoxAnswer = MsgBox(262452, 'This will FORMAT Disk ' & $DiskN[6], 'ALL DATA WILL BE ERASED FROM ' & 'DISK ' & $DiskN[6] & @CRLF & 'Are you sure you want to proceed?') Select Case $iMsgBoxAnswer = 6 ;Yes _FormatGPT($DiskN[6]) _IniWriteGPT() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $mainDrive) Run("cmd /c ..\WinNTSetup_x64.exe", @WorkingDir, @SW_HIDE) _Cleanup() Exit Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf EndIf If $Selection = $Refresh Then GUICtrlSetData($DiskList, _GetInfo()) Until $Selection = $GUI_EVENT_CLOSE _Cleanup() Func _GetInfo() Local $Filtered = '' RunWait("cmd /c diskpart /s cache\list.ini>cache\list.txt", @WorkingDir, @SW_HIDE) ; Only works when compiled if x64 $Array = _StringExplode(FileRead(@WorkingDir & '\cache\list.txt'), @LF) For $RawList = 0 To UBound($Array) - 1 If StringRegExp($Array[$RawList], '(?i)Disk [\d]+') Then $Filtered &= $Array[$RawList] & '|' Next $Filtered = StringRegExpReplace($Filtered, '[\s|]*$', '') ;Removal of spaces, returns, line breaks, and pipes from end of the string _GetDriveLetters() Return $Filtered EndFunc ;==>_GetInfo Func _FormatMBR($Drive) GUISetState(@SW_HIDE) $cleandatFile = FileOpen(@WorkingDir & '\cache\clean.dat', 2) FileWrite($cleandatFile, 'Sel Dis ' & $Drive) FileWrite($cleandatFile, @CRLF & 'clean') FileClose($cleandatFile) $attribdatFile = FileOpen(@WorkingDir & '\cache\attrib.dat', 2) FileWrite($attribdatFile, 'Sel Dis ' & $Drive) FileWrite($attribdatFile, @CRLF & 'attribute disk clear readonly') FileClose($attribdatFile) $scrubdatFile = FileOpen(@WorkingDir & '\cache\scrub.dat', 2) FileWrite($scrubdatFile, 'Sel Dis ' & $Drive) FileWrite($scrubdatFile, @CRLF & 'cre par pri') FileWrite($scrubdatFile, @CRLF & 'format quick fs=NTFS label=MBRscrubber') FileClose($scrubdatFile) $convertFile = FileOpen(@WorkingDir & '\cache\convert.dat', 2) FileWrite($convertFile, 'Sel Dis ' & $Drive) FileWrite($convertFile, @CRLF & 'convert mbr') FileClose($convertFile) $mainFile = FileOpen(@WorkingDir & '\cache\formatmain.dat', 2) FileWrite($mainFile, 'Sel Dis ' & $Drive) FileWrite($mainFile, @CRLF & 'cre par pri') FileWrite($mainFile, @CRLF & 'format quick fs=NTFS label=Windows') FileWrite($mainFile, @CRLF & 'Active') FileWrite($mainFile, @CRLF & 'Assign letter=' & $bootDrive) FileClose($mainFile) ProgressOn("Getting BIOS (MBR) Ready...", "Preparing Disk: ", "0%") ProgressSet(20 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(30 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\scrub.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(40 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(50 & "%", "Resetting Disk Attributes") RunWait("cmd /c diskpart /s cache\attrib.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(60 & "%", "Converting Disk Layout to MBR") RunWait("cmd /c diskpart /s cache\convert.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(80 & "%", "Formatting Windows Partition") RunWait("cmd /c diskpart /s cache\formatmain.dat", @WorkingDir, @SW_HIDE) ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>_FormatMBR Func _FormatGPT($Drive) GUISetState(@SW_HIDE) $cleandatFile = FileOpen(@WorkingDir & '\cache\clean.dat', 2) FileWrite($cleandatFile, 'Sel Dis ' & $Drive) FileWrite($cleandatFile, @CRLF & 'clean') FileClose($cleandatFile) $scrubdatFile = FileOpen(@WorkingDir & '\cache\scrub.dat', 2) FileWrite($scrubdatFile, 'Sel Dis ' & $Drive) FileWrite($scrubdatFile, @CRLF & 'cre par pri') FileWrite($scrubdatFile, @CRLF & 'format quick fs=NTFS label=GPTscrubber') FileClose($scrubdatFile) $attribdatFile = FileOpen(@WorkingDir & '\cache\attrib.dat', 2) FileWrite($attribdatFile, 'Sel Dis ' & $Drive) FileWrite($attribdatFile, @CRLF & 'attribute disk clear readonly') FileClose($attribdatFile) $convertFile = FileOpen(@WorkingDir & '\cache\convert.dat', 2) FileWrite($convertFile, 'Sel Dis ' & $Drive) FileWrite($convertFile, @CRLF & 'convert gpt') FileClose($convertFile) $fsFile = FileOpen(@WorkingDir & '\cache\formatsystem.dat', 2) FileWrite($fsFile, 'Sel Dis ' & $Drive) FileWrite($fsFile, @CRLF & 'cre par efi size=100') FileWrite($fsFile, @CRLF & 'format quick fs=fat32 label=System') FileWrite($fsFile, @CRLF & 'assign letter=' & $bootDrive) FileClose($fsFile) $msrFile = FileOpen(@WorkingDir & '\cache\createmsr.dat', 2) FileWrite($msrFile, 'Sel Dis ' & $Drive) FileWrite($msrFile, @CRLF & 'cre par msr size=16') FileClose($msrFile) $mainFile = FileOpen(@WorkingDir & '\cache\formatmain.dat', 2) FileWrite($mainFile, 'Sel Dis ' & $Drive) FileWrite($mainFile, @CRLF & 'cre par pri') FileWrite($mainFile, @CRLF & 'shrink minimum=450') FileWrite($mainFile, @CRLF & 'format quick fs=ntfs label=Windows') FileWrite($mainFile, @CRLF & 'assign letter=' & $mainDrive) FileClose($mainFile) $reFile = FileOpen(@WorkingDir & '\cache\formatwinre.dat', 2) FileWrite($reFile, 'Sel Dis ' & $Drive) FileWrite($reFile, @CRLF & 'cre par pri') FileWrite($reFile, @CRLF & 'format quick fs=ntfs label=WinRE') FileWrite($reFile, @CRLF & 'set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac') FileClose($reFile) ProgressOn("Getting UEFI (GPT) Ready...", "Preparing Disk: ", "0%") ProgressSet(10 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(15 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\scrub.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(20 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(30 & "%", "Resetting Disk Attributes") RunWait("cmd /c diskpart /s cache\attrib.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(40 & "%", "Converting Disk to GPT") RunWait("cmd /c diskpart /s cache\convert.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(50 & "%", "Formatting System Partition") RunWait("cmd /c diskpart /s cache\formatsystem.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(70 & "%", "Creating MSR") RunWait("cmd /c diskpart /s cache\createmsr.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(80 & "%", "Formatting Windows Partition") RunWait("cmd /c diskpart /s cache\formatmain.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(90 & "%", "Formatting WinRE Partition") RunWait("cmd /c diskpart /s cache\formatwinre.dat", @WorkingDir, @SW_HIDE) ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>_FormatGPT Func _IniWriteMBR() IniWrite("..\WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT6", "TempDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "TempDest", $bootDrive & ":") EndFunc ;==>_IniWriteMBR Func _IniWriteGPT() IniWrite("..\WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT6", "TempDest", $mainDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "TempDest", $mainDrive & ":") EndFunc ;==>_IniWriteGPT Func _Cleanup() Local Const $WDcachePath = @WorkingDir & "\cache" If FileExists($WDcachePath) Then DirRemove($WDcachePath, $DIR_REMOVE) EndIf EndFunc ;==>_Cleanup Func _GetDriveLetters() Local $driveletter = StringSplit("Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C", ",", 1) For $bd = 1 To $driveletter[0] Step +1 $bdStat = DriveStatus($driveletter[$bd] & ":") If $bdStat = "INVALID" Then $bootDrive = ($driveletter[$bd]) For $md = 1 To $driveletter[0] Step +1 $mdStat = DriveStatus($driveletter[$md] & ":") If Not ($bootDrive = ($driveletter[$md])) Then If $mdStat = "INVALID" Then $mainDrive = ($driveletter[$md]) EndIf EndIf Next EndIf Next EndFunc ;==>_GetDriveLetters1 point
-
You can do it all in the _GetInfo function. One less global var ($Filtered) and just return the value for the list. Global $DiskList, $RawList, $Array, $Selection, $MBR, $GPT, $Refresh, $bootDrive, $mainDrive _Cleanup() DirCreate(@WorkingDir & '\cache') $listFile = FileOpen(@WorkingDir & '\cache\list.ini', 2) FileWrite($listFile, 'lis dis') FileClose($listFile) _GetInfo() GUICreate('Prep/Format Disk v1.2', 300, 298) GUISetIcon(@WorkingDir & '\PrepareDiskNT.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('1: Select a disk to prepare for WinNTSetup5', 20, 10, 280) $DiskList = GUICtrlCreateList('', 20, 30, 260, 150) GUICtrlSetData(-1, '') $Refresh = GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('2: Select your desired layout...', 20, 214, 280, 30) $MBR = GUICtrlCreateButton('BIOS (MBR) Boot', 20, 232, 120, 40) $GPT = GUICtrlCreateButton('UEFI (GPT) Boot', 160, 232, 120, 40) GUICtrlCreateLabel('( * ) Disk is Currently GPT', 160, 278, 130, 30) GUISetState() Do $Selection = GUIGetMsg() If $Selection = $MBR Then Local $Disk = StringRegExpReplace(GUICtrlRead($DiskList), '(?i)^.*(Disk [\d]+).*$', '$1') Local $DiskN = StringSplit($Disk, "") Local $iMsgBoxAnswer If $Disk = "" Then MsgBox($MB_ICONERROR, "Notice: ", "No disk has been selected") Else $iMsgBoxAnswer = MsgBox(262452, 'This will FORMAT Disk ' & $DiskN[6], 'ALL DATA WILL BE ERASED FROM ' & 'DISK ' & $DiskN[6] & @CRLF & 'Are you sure you want to proceed?') Select Case $iMsgBoxAnswer = 6 ;Yes _FormatMBR($DiskN[6]) _IniWriteMBR() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $bootDrive) Run("cmd /c ..\WinNTSetup_x64.exe", @WorkingDir, @SW_HIDE) _Cleanup() Exit Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf EndIf If $Selection = $GPT Then Local $Disk = StringRegExpReplace(GUICtrlRead($DiskList), '(?i)^.*(Disk [\d]+).*$', '$1') Local $DiskN = StringSplit($Disk, "") Local $iMsgBoxAnswer If $Disk = "" Then MsgBox($MB_ICONERROR, "Notice: ", "No disk has been selected") Else $iMsgBoxAnswer = MsgBox(262452, 'This will FORMAT Disk ' & $DiskN[6], 'ALL DATA WILL BE ERASED FROM ' & 'DISK ' & $DiskN[6] & @CRLF & 'Are you sure you want to proceed?') Select Case $iMsgBoxAnswer = 6 ;Yes _FormatGPT($DiskN[6]) _IniWriteGPT() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $mainDrive) Run("cmd /c ..\WinNTSetup_x64.exe", @WorkingDir, @SW_HIDE) _Cleanup() Exit Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf EndIf If $Selection = $Refresh Then GUICtrlSetData($DiskList, _GetInfo()) Until $Selection = $GUI_EVENT_CLOSE _Cleanup() Func _GetInfo() Local $Filtered = '' RunWait("cmd /c diskpart /s cache\list.ini>cache\list.txt", @WorkingDir, @SW_HIDE) ; Only works when compiled if x64 $Array = _StringExplode(FileRead(@WorkingDir & '\cache\list.txt'), @LF) For $RawList = 0 To UBound($Array) - 1 If StringRegExp($Array[$RawList], '(?i)Disk [\d]+') Then $Filtered &= $Array[$RawList] & '|' Next $Filtered = StringRegExpReplace($Filtered, '[\s|]*$', '') ;Removal of spaces, returns, line breaks, and pipes from end of the string _GetDriveLetters() Return $Filtered EndFunc ;==>_GetInfo Func _FormatMBR($Drive) GUISetState(@SW_HIDE) $cleandatFile = FileOpen(@WorkingDir & '\cache\clean.dat', 2) FileWrite($cleandatFile, 'Sel Dis ' & $Drive) FileWrite($cleandatFile, @CRLF & 'clean') FileClose($cleandatFile) $attribdatFile = FileOpen(@WorkingDir & '\cache\attrib.dat', 2) FileWrite($attribdatFile, 'Sel Dis ' & $Drive) FileWrite($attribdatFile, @CRLF & 'attribute disk clear readonly') FileClose($attribdatFile) $scrubdatFile = FileOpen(@WorkingDir & '\cache\scrub.dat', 2) FileWrite($scrubdatFile, 'Sel Dis ' & $Drive) FileWrite($scrubdatFile, @CRLF & 'cre par pri') FileWrite($scrubdatFile, @CRLF & 'format quick fs=NTFS label=MBRscrubber') FileClose($scrubdatFile) $convertFile = FileOpen(@WorkingDir & '\cache\convert.dat', 2) FileWrite($convertFile, 'Sel Dis ' & $Drive) FileWrite($convertFile, @CRLF & 'convert mbr') FileClose($convertFile) $mainFile = FileOpen(@WorkingDir & '\cache\formatmain.dat', 2) FileWrite($mainFile, 'Sel Dis ' & $Drive) FileWrite($mainFile, @CRLF & 'cre par pri') FileWrite($mainFile, @CRLF & 'format quick fs=NTFS label=Windows') FileWrite($mainFile, @CRLF & 'Active') FileWrite($mainFile, @CRLF & 'Assign letter=' & $bootDrive) FileClose($mainFile) ProgressOn("Getting BIOS (MBR) Ready...", "Preparing Disk: ", "0%") ProgressSet(20 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(30 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\scrub.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(40 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(50 & "%", "Resetting Disk Attributes") RunWait("cmd /c diskpart /s cache\attrib.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(60 & "%", "Converting Disk Layout to MBR") RunWait("cmd /c diskpart /s cache\convert.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(80 & "%", "Formatting Windows Partition") RunWait("cmd /c diskpart /s cache\formatmain.dat", @WorkingDir, @SW_HIDE) ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>_FormatMBR Func _FormatGPT($Drive) GUISetState(@SW_HIDE) $cleandatFile = FileOpen(@WorkingDir & '\cache\clean.dat', 2) FileWrite($cleandatFile, 'Sel Dis ' & $Drive) FileWrite($cleandatFile, @CRLF & 'clean') FileClose($cleandatFile) $scrubdatFile = FileOpen(@WorkingDir & '\cache\scrub.dat', 2) FileWrite($scrubdatFile, 'Sel Dis ' & $Drive) FileWrite($scrubdatFile, @CRLF & 'cre par pri') FileWrite($scrubdatFile, @CRLF & 'format quick fs=NTFS label=GPTscrubber') FileClose($scrubdatFile) $attribdatFile = FileOpen(@WorkingDir & '\cache\attrib.dat', 2) FileWrite($attribdatFile, 'Sel Dis ' & $Drive) FileWrite($attribdatFile, @CRLF & 'attribute disk clear readonly') FileClose($attribdatFile) $convertFile = FileOpen(@WorkingDir & '\cache\convert.dat', 2) FileWrite($convertFile, 'Sel Dis ' & $Drive) FileWrite($convertFile, @CRLF & 'convert gpt') FileClose($convertFile) $fsFile = FileOpen(@WorkingDir & '\cache\formatsystem.dat', 2) FileWrite($fsFile, 'Sel Dis ' & $Drive) FileWrite($fsFile, @CRLF & 'cre par efi size=100') FileWrite($fsFile, @CRLF & 'format quick fs=fat32 label=System') FileWrite($fsFile, @CRLF & 'assign letter=' & $bootDrive) FileClose($fsFile) $msrFile = FileOpen(@WorkingDir & '\cache\createmsr.dat', 2) FileWrite($msrFile, 'Sel Dis ' & $Drive) FileWrite($msrFile, @CRLF & 'cre par msr size=16') FileClose($msrFile) $mainFile = FileOpen(@WorkingDir & '\cache\formatmain.dat', 2) FileWrite($mainFile, 'Sel Dis ' & $Drive) FileWrite($mainFile, @CRLF & 'cre par pri') FileWrite($mainFile, @CRLF & 'shrink minimum=450') FileWrite($mainFile, @CRLF & 'format quick fs=ntfs label=Windows') FileWrite($mainFile, @CRLF & 'assign letter=' & $mainDrive) FileClose($mainFile) $reFile = FileOpen(@WorkingDir & '\cache\formatwinre.dat', 2) FileWrite($reFile, 'Sel Dis ' & $Drive) FileWrite($reFile, @CRLF & 'cre par pri') FileWrite($reFile, @CRLF & 'format quick fs=ntfs label=WinRE') FileWrite($reFile, @CRLF & 'set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac') FileClose($reFile) ProgressOn("Getting UEFI (GPT) Ready...", "Preparing Disk: ", "0%") ProgressSet(10 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(15 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\scrub.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(20 & "%", "Cleaning Drive") RunWait("cmd /c diskpart /s cache\clean.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(30 & "%", "Resetting Disk Attributes") RunWait("cmd /c diskpart /s cache\attrib.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(40 & "%", "Converting Disk to GPT") RunWait("cmd /c diskpart /s cache\convert.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(50 & "%", "Formatting System Partition") RunWait("cmd /c diskpart /s cache\formatsystem.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(70 & "%", "Creating MSR") RunWait("cmd /c diskpart /s cache\createmsr.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(80 & "%", "Formatting Windows Partition") RunWait("cmd /c diskpart /s cache\formatmain.dat", @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(90 & "%", "Formatting WinRE Partition") RunWait("cmd /c diskpart /s cache\formatwinre.dat", @WorkingDir, @SW_HIDE) ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>_FormatGPT Func _IniWriteMBR() IniWrite("..\WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT6", "TempDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "TempDest", $bootDrive & ":") EndFunc ;==>_IniWriteMBR Func _IniWriteGPT() IniWrite("..\WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT6", "TempDest", $mainDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite("..\WinNTSetup.ini", "WinNT5", "TempDest", $mainDrive & ":") EndFunc ;==>_IniWriteGPT Func _Cleanup() Local Const $WDcachePath = @WorkingDir & "\cache" If FileExists($WDcachePath) Then DirRemove($WDcachePath, $DIR_REMOVE) EndIf EndFunc ;==>_Cleanup Func _GetDriveLetters() Local $driveletter = StringSplit("Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C", ",", 1) For $bd = 1 To $driveletter[0] Step +1 $bdStat = DriveStatus($driveletter[$bd] & ":") If $bdStat = "INVALID" Then $bootDrive = ($driveletter[$bd]) For $md = 1 To $driveletter[0] Step +1 $mdStat = DriveStatus($driveletter[$md] & ":") If Not ($bootDrive = ($driveletter[$md])) Then If $mdStat = "INVALID" Then $mainDrive = ($driveletter[$md]) EndIf EndIf Next EndIf Next EndFunc ;==>_GetDriveLetters1 point
-
Version 3.4
1,395 downloads
The CodeScannerCrypterBundle (ca. 2.9 MB unzipped) contains the following UDFs and utilities: CodeScanner: analyse AutoIt script structure and content, identify potential issues, generate MCF data files CodeCrypter: front-end GUI for the MCF library, for script encryption (without storing the decryption key(s) in the script!) MetaCodeFile UDF (MCF library): for analysis and user-defined alterations of AutoIt script structure and content MCFinclude.au3: #include this UDF in any AutoIt script that you wish CodeCrypter to process CryptoNG, by TheXman; encryption UDF using Bcrypt dll calls (32/64-bit; various algorithms) StoreCCprofile.au3/readCSdatadump.au3/helloworld.au3: auxiliary utilities and example script HowToCodeCrypt.pdf: a simple guide in five steps CodeCrypterFAQ.pdf: questions and answers, partly based upon exchanges in the CodeCrypter thread. MetaCodeTutorial.pdf: the MCF engine explained; useful for encryption, GUI translation, code translation, and much more... Please follow the links for additional information.1 point