Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/18/2021 in all areas

  1. I can't remember where I downloaded the "Simple Library Docs Generator". I have modified the SLDG to create CHM files that look like the AutoIt help file. When I have fixed some formatting and functional bugs, I will post the results in a separate thread.
    3 points
  2. Version 0.1.0

    812 downloads

    ATTENTION! THIS IS STILL WORK IN PROGRESS! This is the modified version of MrCreatoR's "Simple Library Docs Generator". It allows to create CHM help files that look like the AutoIt help file. In additon this CHM files can then be used with Advanced.Help. This a very early alpha version - so it is miles away from being perfect. It's just something for you to play with. The documentation is in the making and will be published as soon as possible. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    2 points
  3. I have played with W7 and W10 and couldn't reproduce your problem Then I set the scaling of the Display to 175% on W10 and got a similar result (but just for the AD.CHM, the AutoIt.CHM always looked correct.) So now I know where I have to look. Will add this to the ToDo list Changing the screen resolution always returned a correct result.
    2 points
  4. JLogan3o13

    Robocopy

    In-Place upgrade of Server OS - 🤮 Didn't realize anyone still did that
    2 points
  5. I use code cert signing from almost 2 years. In my case It solve many problems but not all. Take a look here: Try my TIP to use: If Not @Compiled Then ConsoleWrite('ESET') Currently I have almost zero problem with AV software. My compiled exe are used daily on more than 100 computers.
    1 point
  6. I understand that "Many roads lead to Rome" but .... this is a really much longer road to get there driving around the real issue which is not setting the proper Working directory!
    1 point
  7. Curious if the signing will solve all these False Positives for you. Let us know.
    1 point
  8. yes you can and you also create another unsigned exe that potentially is seen as an virus . It really is a match you can't win, only lose at some point in time!
    1 point
  9. You can also use a tool like 7zSFXConstructor to pack the Au3 and AutoIT3.exe into a single SFX exe.. With that tool you can create a cmd script and during sfx exe creation point to that as the file to execute when the sfx is run.. The tool allows you to pick where you want the file to extract to e.g. %temp% and will self delete the extracted files on process close.. If you do use a cmd script to execute everything inside you can hide the console window completely and use the Start "" ????.cmd to keep the process going until you are finished (for self removal), you can lock running the exe down with a password etc.. An added benefit to the sfx method is that you are executing from removable media, the media can be disconnected after launch while the program is running.. Very simple easy way to package a "compiled" EXE from au3 scripts with AutoIT3.exe without too many headaches... Tool located here: https://github.com/CryptoNickSoft/7z-SFX-Constructor
    1 point
  10. Ok. But instead of abandoning the prior thread, you could have replied to the forum members that tried to assist you and provided additional details. 🙂
    1 point
  11. That disk function works perfectly. Very awesome @benners! Below is the updated script. This and the BurnTool in the other thread share functions and basic gui but both do useful things that will make PE users lives easier.. They arent meant to be beautiful but to replace old cmd scripts.. this is much safer than looking at a disk 0 disk 1 disk 2 list in diskpart Also thank you @junkew for helping teach me #NoTrayIcon #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=PrepareDiskNT.ico #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Comment=Prepare / Format Disks for WinNTSetup #AutoIt3Wrapper_Res_Description=PrepareDiskNT.exe #AutoIt3Wrapper_Res_Fileversion=2.0.0.6 #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #Tidy_Parameters=/sf #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <StringConstants.au3> Global $c_DiskList = 0 Global $c_MBR_btn = 0 Global $c_GPT_btn = 0 Global $s_BootDrive = "" Global $s_MainDrive = "" Cleanup(False) DirCreate(GetCachePath()) Opt("GUIOnEventMode", 1) GUI_Create() Func Buttons_Disable() GUICtrlSetState($c_MBR_btn, $GUI_DISABLE) GUICtrlSetState($c_GPT_btn, $GUI_DISABLE) EndFunc ;==>Buttons_Disable Func Buttons_Enable() GUICtrlSetState($c_MBR_btn, $GUI_ENABLE) GUICtrlSetState($c_GPT_btn, $GUI_ENABLE) EndFunc ;==>Buttons_Enable Func Cleanup($b_Exit = True) If FileExists(GetCachePath()) Then DirRemove(GetCachePath(), $DIR_REMOVE) If $b_Exit Then Exit EndFunc ;==>Cleanup Func DiskList_GetDrives() Local Const $WBEMFLAGRETURNIMMEDIATELY = 0x10 Local Enum _ $Unknown, _ $NoRootDirectory, _ $RemovableDisk, _ $LocalDisk, _ $NetworkDrive, _ $CompactDisk, _ $RAMDisk Local $o_WMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") If IsObj($o_WMIService) Then Local $s_Query = "SELECT * FROM Win32_DiskDrive" Local $o_DiskDrives = $o_WMIService.ExecQuery($s_Query, "WQL", $WBEMFLAGRETURNIMMEDIATELY) If IsObj($o_DiskDrives) Then Local $o_Partitions = 0 Local $o_LogicalDisks = 0 For $o_DiskDrive In $o_DiskDrives $h_Parent = GUICtrlCreateTreeViewItem("Disk " & $o_DiskDrive.Index & " [" & $o_DiskDrive.Model & "]", $c_DiskList) GUICtrlSetOnEvent(-1, 'Buttons_Enable') _GUICtrlTreeView_SetIcon($c_DiskList, $h_Parent, "shell32.dll", 15) $s_Query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $o_DiskDrive.DeviceId & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" $o_Partitions = $o_WMIService.ExecQuery($s_Query) If IsObj($o_Partitions) Then For $o_Partition In $o_Partitions $s_Query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $o_Partition.DeviceId & "'} WHERE AssocClass = Win32_LogicalDiskToPartition" $o_LogicalDisks = $o_WMIService.ExecQuery($s_Query) For $o_LogicalDisk In $o_LogicalDisks If $o_LogicalDisk.drivetype = $RemovableDisk Or $o_LogicalDisk.drivetype = $LocalDisk Then GUICtrlCreateTreeViewItem('(' & $o_LogicalDisk.DeviceId & '\) ' & $o_LogicalDisk.Volumename, $h_Parent) GUICtrlSetOnEvent(-1, 'Buttons_Disable') _GUICtrlTreeView_SetIcon($c_DiskList, -1, "shell32.dll", 7) EndIf Next Next Else ; add error info here EndIf Next Else ; add error info here EndIf Else ; add error info here EndIf EndFunc ;==>DiskList_GetDrives Func DiskList_Load() _GUICtrlTreeView_BeginUpdate($c_DiskList) _GUICtrlTreeView_DeleteAll($c_DiskList) DiskList_GetDrives() If _GUICtrlTreeView_GetCount($c_DiskList) > 2 Then _GUICtrlTreeView_Sort($c_DiskList) _GUICtrlTreeView_Expand($c_DiskList) _GUICtrlTreeView_EndUpdate($c_DiskList) Buttons_Disable() EndFunc ;==>DiskList_Load Func DiskPart_CreateScriptFile($s_FileName, $s_Message) Local $h_File = FileOpen($s_FileName, 2) FileWrite($h_File, $s_Message) FileClose($h_File) EndFunc ;==>DiskPart_CreateScriptFile Func GetCachePath() Local Static $s_CachePath = IniRead(@WorkingDir & '\PrepareDiskNT.ini', "Settings", "CachePath", @WorkingDir & '\cache') & '\' Return $s_CachePath EndFunc ;==>GetCachePath Func GetDriveLetters() Local $s_AllDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ" Local $as_Drives = DriveGetDrive($DT_ALL) If @error Then ; An error occurred when retrieving the drives. MsgBox( _ BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), _ "Drive Letters", _ "Unable to retrieve available drive letters! Exiting Program...") Cleanup() Else Local $s_DriveLetter For $i = 1 To $as_Drives[0] $s_DriveLetter = StringLeft(StringUpper($as_Drives[$i]), 1) $s_AllDriveLetters = StringReplace($s_AllDriveLetters, $s_DriveLetter, "") Next EndIf Local $as_AvailDriveLetters = StringSplit($s_AllDriveLetters, "") $s_BootDrive = $as_AvailDriveLetters[1] ; Get first available letter $s_MainDrive = $as_AvailDriveLetters[2] ; Get second available letter EndFunc ;==>GetDriveLetters Func GPT_Format() GUISetState(@SW_HIDE) Local $as_DiskPart[10][2] = [ _ [9, 0], _ ["Cleaning Drive", 'clean.dat'], _ ["Cleaning Drive", 'scrub.dat'], _ ["Cleaning Drive", 'clean.dat'], _ ["Resetting Disk Attributes", 'attrib.dat'], _ ["Converting Layout to GPT", 'convert.dat'], _ ["Creating System Partition", 'formatsystem.dat'], _ ["Creating MSR Partition", 'createmsr.dat'], _ ["Creating Windows Partition", 'formatmain.dat'], _ ["Creating WinRE Partition", 'formatwinre.dat'] _ ] ProgressOn("Formatting GPT (UEFI)...", "Preparing Disk: ", "0%") For $i = 1 To $as_DiskPart[0][0] ProgressSet($i * 11 & "%", $as_DiskPart[$i][0]) RunWait(@ComSpec & ' /c diskpart /s ' & '"' & GetCachePath() & $as_DiskPart[$i][1] & '"', @WorkingDir, @SW_HIDE) Sleep(750) Next ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>GPT_Format Func GPT_Pressed() Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH) If $s_DiskNumber = "" Then MsgBox( _ $MB_ICONERROR, _ ; it is possible to bug the GUI and make the buttons appear by pressing + or - on tree then refresh "Attention: ", _ "No disk is selected!") Buttons_Disable() Else $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Attention: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then GPT_Prepare($s_DiskNumber) GPT_Format() GPT_WriteIni() MsgBox( _ $MB_ICONINFORMATION, _ "Redirecting... ", _ " - WinNTSetup will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $s_BootDrive & @CRLF & 'Install Drive: ' & $s_MainDrive) WinNTSetup_Launch() Cleanup() EndIf EndIf EndIf EndFunc ;==>GPT_Pressed Func GPT_WriteIni() Local $s_IniFile = WinNTSetup_GetPath() & "WinNTSetup.ini" IniWrite($s_IniFile, "WinNT6", "BootDest", $s_BootDrive & ":") IniWrite($s_IniFile, "WinNT6", "TempDest", $s_MainDrive & ":") IniWrite($s_IniFile, "WinNT5", "BootDest", $s_BootDrive & ":") IniWrite($s_IniFile, "WinNT5", "TempDest", $s_MainDrive & ":") EndFunc ;==>GPT_WriteIni Func GPT_Prepare($s_DiskNumber) GetDriveLetters() DiskPart_CreateScriptFile(GetCachePath() & 'clean.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'clean' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'scrub.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=GPTscrubber' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'attrib.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'convert.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'convert gpt' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'formatsystem.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'cre par efi size=100' & @CRLF & 'format quick fs=fat32 label=System' & @CRLF & 'assign letter=' & $s_BootDrive & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'createmsr.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'cre par msr size=16' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'formatmain.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'cre par pri' & @CRLF & 'shrink minimum=450' & @CRLF & 'format quick fs=ntfs label=Windows' & @CRLF & 'assign letter=' & $s_MainDrive & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'formatwinre.dat', 'Sel Dis ' & $s_DiskNumber & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=ntfs label=WinRE' & @CRLF & 'set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac' & @CRLF & 'Exit') EndFunc ;==>GPT_Prepare Func GUI_Create() GUICreate('Prep/Format Disk v2.0', 300, 289) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close") GUISetIcon(@WorkingDir & '\PrepareDiskNT.ico', 1) GUISetBkColor(0x898989) GUICtrlCreateLabel('1: Select a disk to prepare for WinNTSetup', 20, 10, 280) $c_DiskList = GUICtrlCreateTreeView(10, 30, 280, 150) DiskList_Load() GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetOnEvent(-1, "DiskList_Load") GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('2: Select your desired layout...', 20, 214, 280, 30) $c_MBR_btn = GUICtrlCreateButton('MBR (BIOS) Boot', 20, 234, 120, 40) GUICtrlSetOnEvent(-1, "MBR_Pressed") GUICtrlSetState(-1, $GUI_DISABLE) $c_GPT_btn = GUICtrlCreateButton('GPT (UEFI) Boot', 160, 234, 120, 40) GUICtrlSetOnEvent(-1, "GPT_Pressed") GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() ; Just idle around While 1 Sleep(10) WEnd EndFunc ;==>GUI_Create Func GUI_Close() Cleanup() EndFunc ;==>GUI_Close Func MBR_Format() GUISetState(@SW_HIDE) Local $as_DiskPart[7][2] = [ _ [6, 0], _ ["Cleaning Drive", 'clean.dat'], _ ["Cleaning Drive", 'scrub.dat'], _ ["Cleaning Drive", 'clean.dat'], _ ["Resetting Disk Attributes", 'attrib.dat'], _ ["Converting Layout to MBR", 'convert.dat'], _ ["Creating Windows Partition", 'formatmain.dat'] _ ] ProgressOn("Formatting MBR (BIOS)...", "Preparing Disk: ", "0%") For $i = 1 To $as_DiskPart[0][0] ProgressSet($i * 17 & "%", $as_DiskPart[$i][0]) RunWait(@ComSpec & ' /c diskpart /s ' & '"' & GetCachePath() & $as_DiskPart[$i][1] & '"', @WorkingDir, @SW_HIDE) Sleep(750) Next ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>MBR_Format Func MBR_Prepare($s_Drive) GetDriveLetters() DiskPart_CreateScriptFile(GetCachePath() & 'clean.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'clean' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'scrub.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=MBRscrubber' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'attrib.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'convert.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'convert mbr' & @CRLF & 'Exit') DiskPart_CreateScriptFile(GetCachePath() & 'formatmain.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=Windows' & @CRLF & 'Active' & @CRLF & 'Assign letter=' & $s_BootDrive & @CRLF & 'Exit') EndFunc ;==>MBR_Prepare Func MBR_Pressed() Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH) If $s_DiskNumber = "" Then MsgBox( _ $MB_ICONERROR, _ ; it is possible to bug the GUI and make the buttons appear by pressing + or - on tree then refresh "Attention: ", _ "No disk is selected!") Buttons_Disable() Else $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Attention: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then MBR_Prepare($s_DiskNumber) MBR_Format() MBR_WriteIni() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $s_BootDrive & @CRLF & 'Install Drive: ' & $s_BootDrive) WinNTSetup_Launch() Cleanup() EndIf EndIf EndIf EndFunc ;==>MBR_Pressed Func MBR_WriteIni() Local $s_IniFile = WinNTSetup_GetPath() & "WinNTSetup.ini" IniWrite($s_IniFile, "WinNT6", "BootDest", $s_BootDrive & ":") IniWrite($s_IniFile, "WinNT6", "TempDest", $s_BootDrive & ":") IniWrite($s_IniFile, "WinNT5", "BootDest", $s_BootDrive & ":") IniWrite($s_IniFile, "WinNT5", "TempDest", $s_BootDrive & ":") EndFunc ;==>MBR_WriteIni Func WinNTSetup_GetPath() Local Static $s_WinNTSetupPath = IniRead(@WorkingDir & '\PrepareDiskNT.ini', "Settings", "WinNTSetupPath", @WorkingDir) & '\' If $s_WinNTSetupPath = '\' Then $s_WinNTSetupPath = '' Return $s_WinNTSetupPath EndFunc ;==>WinNTSetup_GetPath Func WinNTSetup_Launch() Run(@ComSpec & ' /c ""' & WinNTSetup_GetPath() & 'WinNTSetup_x64.exe""', @WorkingDir, @SW_HIDE) EndFunc ;==>WinNTSetup_Launch PrepareDiskNT.ini (PrepareDiskNT.exe can be used in the same folder as WinNTSetup.exe, If PrepareDiskNT.ini exists, it can be used to set the relative path to WinNTSetup.exe) [Settings] WinNTSetupPath=
    1 point
  12. Thank you to @benners, for making this awesome DiskList_GetDrives function for GUICtrlCreateTreeView, that is almost as awesome as she is lol..🤩 and sharing it with all of us.. Excellent work my friend. Below is the updated BurnTool This has been put through thorough testing over the last few days in as many scenarios as I could dream up. It seems extremely solid. I hope this source helps others learn as I have. #NoTrayIcon #RequireAdmin #include <StringConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <AutoItConstants.au3> #include <Constants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <MsgBoxConstants.au3> #include <String.au3> #include <WinAPIFiles.au3> Global $c_DiskList = 0 Global $BurnBtn = 0 Global $bootDrive = "" Global $dataDrive = "" Opt("GUIOnEventMode", 1) ISO_CheckWasDropped() ISO_Mount() Global $s_MountedDrive = ISO_GetDriveLetter() BootWim_Check() Cleanup(False) DirCreate(GetCachePath()) MainMenu() Func BootWim_Check() ; check for the boot wim file If Not FileExists($s_MountedDrive & 'sources\boot.wim') Then MsgBox($MB_ICONERROR, "Notice: ", "BOOT.WIM NOT DETECTED!!!" & @CRLF & "This tool is designed for SE" & @CRLF & "and XPE projects only.") ISO_Unmount() Exit EndIf EndFunc ;==>BootWim_Check Func BootWim_GetSize() ; get the boot wim size and add 200 megabytes for headroom on boot partition Return Round((FileGetSize($s_MountedDrive & 'sources\boot.wim') + 209715200) / 1048576) EndFunc ;==>BootWim_GetSize Func BurnPressed() Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH) If $s_DiskNumber = "" Then MsgBox( _ $MB_ICONERROR, _ ; it is possible to bug the GUI and make the buttons appear by pressing + or - on tree then refresh "Attention: ", _ "No disk is selected!") Buttons_Disable() Else Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList, $GUI_READ_EXTENDED), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Notice: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then GUISetState(@SW_HIDE) ProgressOn("BurnTool (XPE/SE) v2.0", "Creating Bootable Media...", "0%") Format_Prepare($s_DiskNumber) ProgressSet(5 & "%", "Formatting Disk " & $s_DiskNumber) Format_Run() ProgressSet(25 & "%", "Analyzing ISO Structure ") CleanDirList() CleanFileList() ProgressSet(26 & "%", "Copying Boot Partition ") CopyBootFiles() ;Progress in function; start at 55% CopyDataFilesF() ;Progress in function; start at 65% CopyDataFilesD() ProgressSet(100, "Finished", "ISO Applied!!") Sleep(2750) ProgressOff() ISO_Unmount() Cleanup(False) MsgBox($MB_ICONINFORMATION, "", " Enjoy! ") Exit EndIf EndIf EndIf EndFunc ;==>BurnPressed Func Buttons_Disable() GUICtrlSetState($BurnBtn, $GUI_DISABLE) EndFunc ;==>Buttons_Disable Func Buttons_Enable() GUICtrlSetState($BurnBtn, $GUI_ENABLE) EndFunc ;==>Buttons_Enable Func CleanDirList() ; setting GetCachePath() as the working directory so dir path needed for the files RunWait(@ComSpec & ' /c DIR /B /A:D ' & $s_MountedDrive & ' > isod.dat', GetCachePath(), @SW_HIDE) RunWait(@ComSpec & ' /c FINDSTR /V /I /C:"efi" /C:"boot" /C:"sources" isod.dat > ' & FinalDirs_GetName(), GetCachePath(), @SW_HIDE) EndFunc ;==>CleanDirList Func CleanFileList() ; setting GetCachePath() as the working directory so need dir path needed for the files RunWait(@ComSpec & ' /c DIR /B /A-D ' & $s_MountedDrive & ' > isof.dat', GetCachePath(), @SW_HIDE) RunWait(@ComSpec & ' /c FINDSTR /V /I /C:"bootmgr" /C:"menu" isof.dat > ' & FinalFiles_GetName(), GetCachePath(), @SW_HIDE) EndFunc ;==>CleanFileList Func Cleanup($b_Exit = True) If FileExists(GetCachePath()) Then DirRemove(GetCachePath(), $DIR_REMOVE) If $b_Exit Then Exit EndFunc ;==>Cleanup Func CopyBootFiles() ProgressSet(27 & "%", "Copying Boot Partition ") RunWait(@ComSpec & ' /c xcopy ' & $s_MountedDrive & 'BOOT ' & $bootDrive & ':\BOOT /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) RunWait('cmd /c xcopy ' & $s_MountedDrive & 'EFI ' & $bootDrive & ':\EFI /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) ProgressSet(40 & "%", "Copying Boot.wim, this may take a while... ") RunWait('cmd /c xcopy ' & $s_MountedDrive & 'sources ' & $bootDrive & ':\sources /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) ProgressSet(50 & "%", "Copying Boot Files ") If FileExists($s_MountedDrive & "BOOTMGR.") Then RunWait('cmd /c xcopy ' & $s_MountedDrive & 'BOOTMGR. ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) If FileExists($s_MountedDrive & "bootmgr.efi") Then RunWait('cmd /c xcopy ' & $s_MountedDrive & 'bootmgr.efi ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) If FileExists($s_MountedDrive & "bootmgr.exe") Then RunWait('cmd /c xcopy ' & $s_MountedDrive & 'bootmgr.exe ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) If FileExists($s_MountedDrive & "menu.lst") Then RunWait('cmd /c xcopy ' & $s_MountedDrive & 'menu.lst ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) EndFunc ;==>CopyBootFiles Func CopyDataFilesD() Local $GoFiles = (GetCachePath() & FinalDirs_GetName()), $StartProgAt, $xcopycmd, $line = "" FileOpen($GoFiles, 0) Local $aArray[1000] ReDim $aArray[_FileCountLines($GoFiles) + 1] For $i = 1 To _FileCountLines($GoFiles) $newline = FileReadLine($GoFiles, $i) $aArray[$i] = $newline Next _ArraySort($aArray) $StartProgAt = 65 For $i = 1 To UBound($aArray) - 1 If $aArray[$i] = "Programs" Then ProgressSet($StartProgAt & "%", "Copying Programs Folder, this may take a while...") RunWait('cmd /c xcopy ' & $s_MountedDrive & $aArray[$i] & ' ' & $dataDrive & ':\' & $aArray[$i] & ' /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE, 2) $StartProgAt = ($StartProgAt + 15) Else ProgressSet($StartProgAt & "%", "Copying " & $aArray[$i] & " Folder") RunWait('cmd /c xcopy ' & $s_MountedDrive & $aArray[$i] & ' ' & $dataDrive & ':\' & $aArray[$i] & ' /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE, 2) $StartProgAt = ($StartProgAt + 1) EndIf Next EndFunc ;==>CopyDataFilesD Func CopyDataFilesF() Local $GoFiles = (GetCachePath() & FinalFiles_GetName()), $StartProgAt, $xcopycmd, $line = "" FileOpen($GoFiles, 0) Local $aArray[1000] ReDim $aArray[_FileCountLines($GoFiles) + 1] For $i = 1 To _FileCountLines($GoFiles) $newline = FileReadLine($GoFiles, $i) $aArray[$i] = $newline Next _ArraySort($aArray) $StartProgAt = 55 For $i = 1 To UBound($aArray) - 1 ProgressSet($StartProgAt & "%", "Copying " & $aArray[$i]) RunWait('cmd /c xcopy ' & $s_MountedDrive & $aArray[$i] & ' ' & $dataDrive & ':\' & ' /h /r /v /y', @WorkingDir, @SW_HIDE, 2) $StartProgAt = ($StartProgAt + 1) Next EndFunc ;==>CopyDataFilesF Func Diskpart_CreateScriptFile($s_File, $s_Data) Local $CacheFile = FileOpen(GetCachePath() & $s_File, 2) FileWrite($CacheFile, $s_Data) FileClose($CacheFile) EndFunc ;==>Diskpart_CreateScriptFile Func FinalDirs_GetName() ; get the name for the final dirs to copy Return 'isodirs.dat' EndFunc ;==>FinalDirs_GetName Func FinalFiles_GetName() ; get the names of the final files to copy Return 'isofiles.dat' EndFunc ;==>FinalFiles_GetName Func Format_Prepare($s_Drive) GetDriveLetters() Diskpart_CreateScriptFile('clean.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'clean' & @CRLF & 'Exit') Diskpart_CreateScriptFile('attrib.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') Diskpart_CreateScriptFile('scrubber.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=scrubber' & @CRLF & 'Exit') Diskpart_CreateScriptFile('convert.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'convert mbr' & @CRLF & 'Exit') Diskpart_CreateScriptFile('initdata.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'cre par pri' & @CRLF & 'shrink minimum=' & BootWim_GetSize() & @CRLF & 'format quick fs=ntfs label="WinPE Data"' & @CRLF & 'assign letter=' & $dataDrive & @CRLF & 'Exit') Diskpart_CreateScriptFile('initboot.dat', 'Sel Dis ' & $s_Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=fat32 label="BOOTFILES"' & @CRLF & 'assign letter=' & $bootDrive & @CRLF & 'Active' & @CRLF & 'Exit') EndFunc ;==>Format_Prepare Func Format_Run() Local $aArray[7][3] = [ _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'scrub.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Resetting Disk Attributes", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'attrib.dat' & '"'], _ ["Converting Layout to MBR", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'convert.dat' & '"'], _ ["Creating Data Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'initdata.dat' & '"'], _ ["Creating Boot Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'initboot.dat' & '"'] _ ] For $i = 0 To UBound($aArray) - 1 ProgressSet($i * 2 & "%", $aArray[$i][0]) ;~ ConsoleWrite('cmd: ' & $aArray[$i][1] & @CRLF) RunWait($aArray[$i][1], @WorkingDir, @SW_HIDE) Sleep(750) Next EndFunc ;==>Format_Run Func GetCachePath() ; get the path to the cache folder Local Static $s_CachePath = IniRead(@WorkingDir & '\USBTool.ini', "Settings", "CachePath", @WorkingDir & '\cache') & '\' Return $s_CachePath EndFunc ;==>GetCachePath ; #### this is excellent. who did this? Func DiskList_GetDrives() Local Const $WBEMFLAGRETURNIMMEDIATELY = 0x10 Local Enum _ $Unknown, _ $NoRootDirectory, _ $RemovableDisk, _ $LocalDisk, _ $NetworkDrive, _ $CompactDisk, _ $RAMDisk Local $o_WMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") If IsObj($o_WMIService) Then Local $s_Query = "SELECT * FROM Win32_DiskDrive" Local $o_DiskDrives = $o_WMIService.ExecQuery($s_Query, "WQL", $WBEMFLAGRETURNIMMEDIATELY) If IsObj($o_DiskDrives) Then Local $o_Partitions = 0 Local $o_LogicalDisks = 0 For $o_DiskDrive In $o_DiskDrives $h_Parent = GUICtrlCreateTreeViewItem("Disk " & $o_DiskDrive.Index & " [" & $o_DiskDrive.Model & "]", $c_DiskList) GUICtrlSetOnEvent(-1, 'Buttons_Enable') _GUICtrlTreeView_SetIcon($c_DiskList, $h_Parent, "shell32.dll", 15) $s_Query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $o_DiskDrive.DeviceId & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" $o_Partitions = $o_WMIService.ExecQuery($s_Query) If IsObj($o_Partitions) Then For $o_Partition In $o_Partitions $s_Query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $o_Partition.DeviceId & "'} WHERE AssocClass = Win32_LogicalDiskToPartition" $o_LogicalDisks = $o_WMIService.ExecQuery($s_Query) For $o_LogicalDisk In $o_LogicalDisks If $o_LogicalDisk.drivetype = $RemovableDisk Or $o_LogicalDisk.drivetype = $LocalDisk Then GUICtrlCreateTreeViewItem('(' & $o_LogicalDisk.DeviceId & '\) ' & $o_LogicalDisk.Volumename, $h_Parent) GUICtrlSetOnEvent(-1, 'Buttons_Disable') _GUICtrlTreeView_SetIcon($c_DiskList, -1, "shell32.dll", 7) EndIf Next Next Else ; add error info here EndIf Next Else ; add error info here EndIf Else ; add error info here EndIf EndFunc ;==>DiskList_GetDrives Func GetDriveLetters() Local $allDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ", $AvailDriveLetters Local $aArray = DriveGetDrive($DT_ALL) If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "An Error Occurred! Unable to retrieve " & @CRLF & "available drive letters! Exiting Program...") ISO_Unmount() Cleanup() Else For $i = 1 To $aArray[0] $driveLetter = StringLeft(StringUpper($aArray[$i]), 1) $allDriveLetters = StringReplace($allDriveLetters, $driveLetter, "") Next EndIf $AvailDriveLetters = StringSplit($allDriveLetters, "") $bootDrive = $AvailDriveLetters[1] ; Get first available letter $dataDrive = $AvailDriveLetters[2] ; Get second available letter ;~ ConsoleWrite('boot drive: ' & $bootDrive & @CRLF) ;~ ConsoleWrite('data drive: ' & $dataDrive & @CRLF) EndFunc ;==>GetDriveLetters Func ISO_CheckWasDropped() ; check that an iso was dropped on to the exe If $CmdLine[0] = 0 Then ; no file was dropped or passed via the command line MsgBox( _ $MB_ICONERROR, _ "Attention: ", _ "This program cannot be run directly!" & @CRLF & "Please drag an ISO onto the program to begin...") Exit EndIf EndFunc ;==>ISO_CheckWasDropped Func ISO_GetDriveLetter() ; get the drive letter of the mounted iso ;~ Local $s_MarkerFile = 'CdUsb.Y' Local $s_MarkerFile = 'BOOTMGR' Local $s_IsoDrive = '' Local $as_CDROM = DriveGetDrive($DT_CDROM) For $i = 1 To $as_CDROM[0] If FileExists($as_CDROM[$i] & '\' & $s_MarkerFile) Then If Not _WinAPI_IsWritable($as_CDROM[$i]) Then $s_IsoDrive = $as_CDROM[$i] & '\' EndIf Next If $s_IsoDrive = "" Then MsgBox( _ $MB_ICONERROR, _ "Attention: ", _ $s_MarkerFile & " NOT DETECTED!!!" & @CRLF & "This tool is designed for XPE" & @CRLF & "and SE projects only.") Exit EndIf Return $s_IsoDrive EndFunc ;==>ISO_GetDriveLetter Func ISO_Mount() ; mount the droppped iso RunWait('cmd /c powershell.exe ' & '"Mount-DiskImage "' & '"' & $CmdLine[1] & '"' & '"' & '"' & ' >nul', @WorkingDir, @SW_HIDE) EndFunc ;==>ISO_Mount Func ISO_Unmount() ; unmount the dropped iso RunWait('cmd /c powershell.exe ' & '"Dismount-DiskImage "' & '"' & $CmdLine[1] & '"' & '"' & '"' & ' >nul', @WorkingDir, @SW_HIDE) EndFunc ;==>ISO_Unmount Func MainMenu() ; draw the gui GUICreate('BurnTool (XPE/SE) v2.0', 300, 287) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close") GUISetIcon(@WorkingDir & '\USBTool.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('Select a disk to use...', 20, 10, 280) $c_DiskList = GUICtrlCreateTreeView(10, 30, 280, 150) DiskList_Load() GUICtrlCreateButton('Refresh List', 110, 187, 80, 25) GUICtrlSetOnEvent(-1, "DiskList_Load") GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('________________________________________', 30, 210, 280, 30) $BurnBtn = GUICtrlCreateButton('Burn', 90, 232, 120, 40) GUICtrlSetOnEvent(-1, "BurnPressed") GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() ; Just idle around While 1 Sleep(10) WEnd EndFunc ;==>MainMenu Func DiskList_Load() _GUICtrlTreeView_BeginUpdate($c_DiskList) _GUICtrlTreeView_DeleteAll($c_DiskList) DiskList_GetDrives() If _GUICtrlTreeView_GetCount($c_DiskList) > 2 Then _GUICtrlTreeView_Sort($c_DiskList) _GUICtrlTreeView_Expand($c_DiskList) _GUICtrlTreeView_EndUpdate($c_DiskList) Buttons_Disable() EndFunc ;==>DiskList_Load Func GUI_Close() ISO_Unmount() Cleanup() EndFunc ;==>GUI_Close
    1 point
  13. I found some reference and example which can be used to build an WD_** function which will give current zoom ratio. https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#example https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#monitoring_screen_resolution_or_zoom_level_changes Here are an interesting examples: https://stackoverflow.com/questions/16541676/what-are-best-practices-for-detecting-pixel-ratio-density Just simple it is a need to check: and AutoIt example: Func _WD_GetDevicePixelRatio($sSession) Local Const $sFuncName = "_WD_GetDevicePixelRatio" Local $sResponse = _WD_ExecuteScript($sSession, "return window.devicePixelRatio", Default, Default) If @error <> $_WD_ERROR_Success Then _ Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception), "") Local $oJSON = Json_Decode($sResponse) Local $iResult = Json_Get($oJSON, "[value]") Return SetError($_WD_ERROR_Success, 0, $iResult) EndFunc ;==>_WD_GetDevicePixelRatio
    1 point
  14. Here's another way to do it #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> GUICreate("bobomb", 400, 288, 722, 322) Global $c_Treeview = GUICtrlCreateTreeView(16, 8, 369, 217) Disk_GetList() _GUICtrlTreeView_Sort($c_Treeview) $Button1 = GUICtrlCreateButton("Button1", 96, 240, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 184, 240, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Disk_GetList() Local Const $WBEMFLAGRETURNIMMEDIATELY = 0x10 Local Enum _ $UNKNOWN, _ $NOROOTDIRECTORY, _ $REMOVABLEDISK, _ $LOCALDISK, _ $NETWORKDRIVE, _ $COMPACTDISK, _ $RAMDISK Local $o_WMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") If IsObj($o_WMIService) Then Local $s_Query = "SELECT * FROM Win32_DiskDrive" Local $o_DiskDrives = $o_WMIService.ExecQuery($s_Query, "WQL", $WBEMFLAGRETURNIMMEDIATELY) If IsObj($o_DiskDrives) Then Local $o_Partitions = 0 Local $o_LogicalDisks = 0 For $o_DiskDrive In $o_DiskDrives $h_Parent = GUICtrlCreateTreeViewItem("Disk " & $o_DiskDrive.Index & " [" & $o_DiskDrive.Model & "]", $c_Treeview) $s_Query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $o_DiskDrive.DeviceId & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" $o_Partitions = $o_WMIService.ExecQuery($s_Query) If IsObj($o_Partitions) Then For $o_Partition In $o_Partitions $s_Query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $o_Partition.DeviceId & "'} WHERE AssocClass = Win32_LogicalDiskToPartition" $o_LogicalDisks = $o_WMIService.ExecQuery($s_Query) For $o_LogicalDisk In $o_LogicalDisks If $o_LogicalDisk.drivetype = $REMOVABLEDISK Or $o_LogicalDisk.drivetype = $LOCALDISK Then GUICtrlCreateTreeViewItem('(' & $o_LogicalDisk.DeviceId & '\) ' & $o_LogicalDisk.Volumename, $h_Parent) EndIf Next Next Else ; add error info here EndIf Next Else ; add error info here EndIf Else ; add error info here EndIf EndFunc ;==>Disk_GetList
    1 point
  15. StringInStr returns either 0 if not found or a number relating to the position of the substring. You are checking to see if it's -1, which it will never be. If you want to run code if the string is found then use If $iExists Then... or If $iExists > 0 or If Not $iExists Then.. or If $iExists = 0 Then
    1 point
  16. Search around for winmgts in the forums then you can query directly all stuff with WMI
    1 point
  17. The reason is due to ramdisks or drives with no letter. _WinAPI_GetDriveNumber is returning an error. If we allow for that by skipping, we have a blank in the array. When the array is sorted on multi-columns, the blanks would mess up the line up. To get around this, we would need to use _ArrayDelete, this uses ReDim and thats what I wanted to get away from with the other code. It would redim after every delete which is worse than the working code. The code you posted that is working would be the better choice, and ditch mine for the DiskList_Load function. We can look at loading the list from the function or leave it returning the string and using GuiCtrlSetData. #NoTrayIcon #RequireAdmin #include <StringConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ListBoxConstants.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> Global $c_DiskList = 0 Global $MBR = 0 Global $GPT = 0 Global $bootDrive = "" Global $mainDrive = "" Cleanup() DirCreate(GetCachePath()) Opt("GUIOnEventMode", 1) MainMenu() Cleanup() Exit Func MainMenu() GUICreate('Prep/Format Disk v2.0', 300, 289) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetIcon(@WorkingDir & '\PrepareDiskNT.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('1: Select a disk to prepare for WinNTSetup5', 20, 10, 280) $c_DiskList = GUICtrlCreateList('', 20, 30, 260, 150, BitXOR($GUI_SS_DEFAULT_LIST, $LBS_SORT)) GUICtrlSetData(-1, GetDiskList()) GUICtrlSetOnEvent(-1, "DiskList_Selected") $Refresh = GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetOnEvent(-1, "RefreshPressed") GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('2: Select your desired layout...', 20, 214, 280, 30) $MBR = GUICtrlCreateButton('BIOS (MBR) Boot', 20, 234, 120, 40) GUICtrlSetOnEvent(-1, "MBRPressed") GUICtrlSetState(-1, $GUI_DISABLE) $GPT = GUICtrlCreateButton('UEFI (GPT) Boot', 160, 234, 120, 40) GUICtrlSetOnEvent(-1, "GPTPressed") GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() ; Just idle around While 1 Sleep(10) WEnd EndFunc ;==>MainMenu Func RefreshPressed() GUICtrlSetData($c_DiskList, "") GUICtrlSetData($c_DiskList, GetDiskList()) DiskList_Selected() EndFunc ;==>RefreshPressed Func MBRPressed() Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Notice: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then PrepMBR($s_DiskNumber) FormatMBR() IniWriteMBR() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $bootDrive) LaunchWinNTSetup() Cleanup() Exit EndIf EndIf EndFunc ;==>MBRPressed Func GPTPressed() Local $s_DiskNumber = StringRegExp(GUICtrlRead($c_DiskList), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Notice: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then PrepGPT($s_DiskNumber) FormatGPT() IniWriteGPT() MsgBox($MB_ICONINFORMATION, "Redirecting... ", " - WinNTSetup5 will now open - " & @CRLF & @CRLF & 'Boot Drive: ' & $bootDrive & @CRLF & 'Install Drive: ' & $mainDrive) LaunchWinNTSetup() Cleanup() Exit EndIf EndIf EndFunc ;==>GPTPressed Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ; Code below for actions on Close Cleanup() Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ; Code below for actions on Minimize Case @GUI_CtrlId = $GUI_EVENT_RESTORE ; Code below for actions on Restore EndSelect EndFunc ;==>SpecialEvents Func Disk_GetName($i_DiskNumber) Local $s_DiskKey = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", String($i_DiskNumber)) If @error Then Return SetError(1, 0, 0) Local $s_DiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $s_DiskKey, "FriendlyName") If $s_DiskName = "" Then $s_DiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $s_DiskKey, "DeviceDesc") Return $s_DiskName EndFunc ;==>Disk_GetName Func GetDiskList() Local $aDriveInfo, $iLastDevNumber = -1 Local $aFixed = DriveGetDrive('FIXED'), $aRemovable = DriveGetDrive('REMOVABLE') Local $aDrives[(IsArray($aFixed) ? $aFixed[0] : 0) + (IsArray($aRemovable) ? $aRemovable[0] : 0)][3] Local $iDrive = 0 GUICtrlSetData($c_DiskList, "") ; clear previous list info For $i = 1 To UBound($aFixed) - 1 $aDrives[$iDrive][0] = $aFixed[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aFixed[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next For $i = 1 To UBound($aRemovable) - 1 $aDrives[$iDrive][0] = $aRemovable[$i] $aDriveInfo = _WinAPI_GetDriveNumber($aRemovable[$i]) If Not @error Then $aDrives[$iDrive][1] = $aDriveInfo[1] $aDrives[$iDrive][2] = $aDriveInfo[2] EndIf $iDrive += 1 Next _ArraySort($aDrives, 0, 0, 0, 1) Local $aDisks[UBound($aDrives)][2] Local $sOutput = "" For $i = 0 To UBound($aDrives) - 1 If IsNumber($aDrives[$i][1]) Then If $aDrives[$i][1] <> $iLastDevNumber Then $iLastDevNumber = $aDrives[$i][1] $aDisks[$iLastDevNumber][0] = " Disk " & $aDrives[$i][1] & " [" & Disk_GetName($aDrives[$i][1]) & "]" & "|" & @CRLF EndIf $aDisks[$iLastDevNumber][1] &= "; â”” " & DriveGetLabel($aDrives[$i][0]) & " - " & "(" & StringUpper($aDrives[$i][0]) & "\ )" & "|" EndIf Next ReDim $aDisks[$iLastDevNumber + 1][2] For $i = 0 To UBound($aDisks) - 1 $sOutput &= $aDisks[$i][0] $aSplit = StringRegExp($aDisks[$i][1], "[^;]+", 3) _ArraySort($aSplit) For $j = 0 To UBound($aSplit) - 1 $sOutput &= $aSplit[$j] Next ;$sOutput &= @CRLF Next Return $sOutput EndFunc ;==>GetDiskList Func DiskList_Selected() ; action when a list item is selected Local $i_State = $GUI_ENABLE If GUICtrlRead($c_DiskList) = '' Or StringInStr(GUICtrlRead($c_DiskList), " â”” ") Then $i_State = $GUI_DISABLE GUICtrlSetState($MBR, $i_State) GUICtrlSetState($GPT, $i_State) EndFunc ;==>DiskList_Selected Func GetDriveLetters() Local $allDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ", $AvailDriveLetters Local $aArray = DriveGetDrive($DT_ALL) If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "An Error Occurred! Unable to retrieve " & @CRLF & "available drive letters! Exiting Program...") Cleanup() Exit Else For $i = 1 To $aArray[0] $driveLetter = StringLeft(StringUpper($aArray[$i]), 1) $allDriveLetters = StringReplace($allDriveLetters, $driveLetter, "") Next EndIf $AvailDriveLetters = StringSplit($allDriveLetters, "") $bootDrive = $AvailDriveLetters[1] ;Get first available letter $mainDrive = $AvailDriveLetters[2] ;Get second available letter EndFunc ;==>GetDriveLetters Func GetWinNTSetupPath() Local Static $s_WinNTSetupPath = IniRead(@WorkingDir & '\PrepareDiskNT.ini', "Settings", "WinNTSetupPath", @WorkingDir & '\') Return $s_WinNTSetupPath EndFunc ;==>GetWinNTSetupPath Func GetCachePath() ; get the path to the cache folder Local Static $s_CachePath = IniRead(@WorkingDir & '\PrepareDiskNT.ini', "Settings", "CachePath", @WorkingDir & '\cache') & '\' Return $s_CachePath EndFunc ;==>GetCachePath Func IniWriteMBR() IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT6", "TempDest", $bootDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT5", "TempDest", $bootDrive & ":") EndFunc ;==>IniWriteMBR Func IniWriteGPT() IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT6", "BootDest", $bootDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT6", "TempDest", $mainDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT5", "BootDest", $bootDrive & ":") IniWrite(GetWinNTSetupPath() & "WinNTSetup.ini", "WinNT5", "TempDest", $mainDrive & ":") EndFunc ;==>IniWriteGPT Func LaunchWinNTSetup() Run('cmd /c ' & '"' & GetWinNTSetupPath() & 'WinNTSetup_x64.exe' & '"', @WorkingDir, @SW_HIDE) EndFunc ;==>LaunchWinNTSetup Func Cleanup() If FileExists(GetCachePath()) Then DirRemove(GetCachePath(), $DIR_REMOVE) EndIf EndFunc ;==>Cleanup Func PrepMBR($Drive) GetDriveLetters() createDiskPartScriptFile(GetCachePath() & 'clean.dat', 'Sel Dis ' & $Drive & @CRLF & 'clean' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'scrub.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=MBRscrubber' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'attrib.dat', 'Sel Dis ' & $Drive & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'convert.dat', 'Sel Dis ' & $Drive & @CRLF & 'convert mbr' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'formatmain.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=Windows' & @CRLF & 'Active' & @CRLF & 'Assign letter=' & $bootDrive & @CRLF & 'Exit') EndFunc ;==>PrepMBR Func PrepGPT($Drive) GetDriveLetters() createDiskPartScriptFile(GetCachePath() & 'clean.dat', 'Sel Dis ' & $Drive & @CRLF & 'clean' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'scrub.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=GPTscrubber' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'attrib.dat', 'Sel Dis ' & $Drive & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'convert.dat', 'Sel Dis ' & $Drive & @CRLF & 'convert gpt' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'formatsystem.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par efi size=100' & @CRLF & 'format quick fs=fat32 label=System' & @CRLF & 'assign letter=' & $bootDrive & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'createmsr.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par msr size=16' & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'formatmain.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'shrink minimum=450' & @CRLF & 'format quick fs=ntfs label=Windows' & @CRLF & 'assign letter=' & $mainDrive & @CRLF & 'Exit') createDiskPartScriptFile(GetCachePath() & 'formatwinre.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=ntfs label=WinRE' & @CRLF & 'set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac' & @CRLF & 'Exit') EndFunc ;==>PrepGPT Func createDiskPartScriptFile($fileName, $message) $CacheFile = '' $CacheFile = FileOpen($fileName, 2) FileWrite($CacheFile, $message) FileClose($CacheFile) EndFunc ;==>createDiskPartScriptFile Func FormatMBR() GUISetState(@SW_HIDE) Local $aArray[6][3] = [ _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'scrub.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Resetting Disk Attributes", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'attrib.dat' & '"'], _ ["Converting Layout to MBR", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'convert.dat' & '"'], _ ["Creating Windows Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'formatmain.dat' & '"'] _ ] ProgressOn("Formatting Legacy (MBR)...", "Preparing Disk: ", "0%") For $i = 0 To UBound($aArray) - 1 ProgressSet($i * 17 & "%", $aArray[$i][0]) ;MsgBox($MB_ICONINFORMATION, "Troubleshooting.. ", $aArray[$i][1]) ;Troubleshoot Array Data RunWait($aArray[$i][1], @WorkingDir, @SW_HIDE) Sleep(750) Next ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>FormatMBR Func FormatGPT() GUISetState(@SW_HIDE) Local $aArray[9][3] = [ _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'scrub.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'clean.dat' & '"'], _ ["Resetting Disk Attributes", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'attrib.dat' & '"'], _ ["Converting Layout to GPT", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'convert.dat' & '"'], _ ["Creating System Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'formatsystem.dat' & '"'], _ ["Creating MSR Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'createmsr.dat' & '"'], _ ["Creating Windows Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'formatmain.dat' & '"'], _ ["Creating WinRE Partition", 'cmd /c diskpart /s ' & '"' & GetCachePath() & 'formatwinre.dat' & '"'] _ ] ProgressOn("Formatting UEFI (GPT)...", "Preparing Disk: ", "0%") For $i = 0 To UBound($aArray) - 1 ProgressSet($i * 11 & "%", $aArray[$i][0]) ;MsgBox($MB_ICONINFORMATION, "Troubleshooting.. ", $aArray[$i][1]) ;Troubleshoot Array Data RunWait($aArray[$i][1], @WorkingDir, @SW_HIDE) Sleep(750) Next ProgressSet(100, "Finished", "Format Completed") Sleep(1500) ProgressOff() GUISetState() EndFunc ;==>FormatGPT
    1 point
  18. Take a screenshot of your desktop (works even if the desktop is hidden), then redraws it row by row. Makes a neat little effect. An effect I remember seeing at the photo booth at Chuck E' Cheese. I mostly just wanted to mess with LockBits and PrintWindow and thought this was a decent way to figure it out, but I liked the outcome and thought I'd share lol #include <GDIPlus.au3> #include <WinApi.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $tDesktopMetrics = GetDesktopMetrics() Global $hHBitmapDesktop = CaptureWindow("", -1, -1, -1, -1, "Program Manager") Global $hBitmapDesktop = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmapDesktop) _WinAPI_DeleteObject($hHBitmapDesktop) Global $iW = _GDIPlus_ImageGetWidth($hBitmapDesktop) Global $iH = _GDIPlus_ImageGetHeight($hBitmapDesktop) Global $tBitmapData = _GDIPlus_BitmapLockBits($hBitmapDesktop, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32PARGB) Global $tPixelMap = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData, "Scan0")) Global $hGui = GUICreate("Redraw", $iW, $iH, $tDesktopMetrics.x, $tDesktopMetrics.y, $WS_POPUP) Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Global $tBitmapData2 = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32PARGB) Global $tPixelMap2 = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData2, "Scan0")) GUISetState(@SW_SHOW, $hGui) _GDIPlus_GraphicsClear($hGraphics) For $iY = 0 To $iH - 1 Local $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 ;get each pixel in each line and row DllStructSetData($tPixelMap2, 1, DllStructGetData($tPixelMap, 1, $iRowOffset + $iX), $iRowOffset + $iX) Next If (Not Mod($iY, 5)) Then ; Every 5 rows draw the bitmap _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData2) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $tBitmapData2 = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32PARGB) $tPixelMap2 = DllStructCreate("int[" & $iW * $iH & "];", DllStructGetData($tBitmapData2, "Scan0")) EndIf Next If (Mod($iY, 5)) Then ; Didn't end on an even row, clean up _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData2) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $tPixelMap2 = 0 $tBitmapData2 = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmapDesktop, $tBitmapData) _GDIPlus_BitmapDispose($hBitmapDesktop) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGui) Exit 0 Func CaptureWindow($sFileName = "", $iLeft = -1, $iTop = -1, $iWidth = -1, $iHeight = -1, $hWnd = WinGetHandle("[Active]"), $bClientArea = True) If (Not IsHWnd($hWnd)) Then $hWnd = WinGetHandle($hWnd) If (@error) Then Return SetError(1, 0, False) If (BitAND(WinGetState($hWnd), 16) = 16) Then Return SetError(2, 0, False) Local $iSrcWidth = 0 Local $iSrcHeight = 0 ConsoleWrite($iLeft & ', ' & $iTop & ", " & $iWidth & ', ' & $iHeight & @LF) If ($hWnd = _WinAPI_GetDesktopWindow() Or $hWnd = WinGetHandle("Program Manager")) Then Local $tDesktop = GetDesktopMetrics() If ($iWidth = -1 Or $iWidth = 0 Or $iWidth = Default Or $iWidth > DllStructGetData($tDesktop, 3)) Then $iWidth = DllStructGetData($tDesktop, 3) If ($iHeight = -1 Or $iHeight = 0 Or $iHeight = Default Or $iWidth > DllStructGetData($tDesktop, 4)) Then $iHeight = DllStructGetData($tDesktop, 4) $iSrcWidth = DllStructGetData($tDesktop, 3) $iSrcHeight = DllStructGetData($tDesktop, 4) Else Local $tRectWindow = _WinAPI_GetWindowRect($hWnd) ; Get the absolute width, using Abs on all of the memembers because the [1] index of the struct may be negative, supports multiple monitors Local $iAbsWidth = Abs(Abs(DllStructGetData($tRectWindow, 3)) - Abs(DllStructGetData($tRectWindow, 1))) ; Get the absolute height, using Abs on all of the memembers because the [1] index of the struct may be negative, supports multiple monitors ; Subtracts the caption bar if $bClientArea only Local $iAbsHeight = Abs(Abs(DllStructGetData($tRectWindow, 4)) - Abs(DllStructGetData($tRectWindow, 2))) - ($bClientArea ? _WinAPI_GetSystemMetrics($SM_CYCAPTION) : 0) If ($iWidth = -1 Or $iWidth = 0 Or $iWidth = Default Or $iWidth > $iAbsWidth) Then $iWidth = $iAbsWidth If ($iHeight = -1 Or $iHeight = 0 Or $iHeight = Default Or $iHeight > $iAbsHeight) Then $iHeight = $iAbsHeight $iSrcWidth = $iAbsWidth $iSrcHeight = $iAbsHeight EndIf If ($iLeft = -1 Or $iLeft = Default) Then $iLeft = 0 If ($iTop = -1 Or $iTop = Default) Then $iTop = 0 Local $hDC = _WinAPI_GetWindowDC($hWnd) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hDestBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hDestBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iSrcWidth, $iSrcHeight) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) _WinAPI_PrintWindow($hWnd, $hSrcDC, True) _WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, $iLeft, $iTop, $MERGECOPY) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) $tPoint = 0 $tRectWindow = 0 $tDesktop = 0 If ($sFileName) Then _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hDestBitmap) _GDIPlus_ImageSaveToFile($hBitmap, $sFileName) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndIf Return $hDestBitmap EndFunc ;==>CaptureWindow Func GetDesktopMetrics() Return _GDIPlus_RectFCreate(_WinAPI_GetSystemMetrics($SM_XVIRTUALSCREEN), _WinAPI_GetSystemMetrics($SM_YVIRTUALSCREEN), _ _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN), _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)) EndFunc ;==>GetDesktopMetrics
    1 point
  19. Yep. I'm finally caving and buying myself a EV Signing Cert likely during US Tax season just to prevent future FP Issues.
    0 points
×
×
  • Create New...