Sign in to follow this  
Followers 0
hackersarchangel

Chkdsk project under WinPE

2 posts in this topic

#1 ·  Posted (edited)

Ok I'm starting work on a project that will be automating chkdsk under a Windows PE based enviroment. Since the final project will be open source, I'm inviting people to join the team in helping make it a successful project and once it's developed to a 1.0 stage, it will mostly be bugfixes/corrections from there on out. I have already made a basic GUI that I will attach to the thread later when I'm at the computer I have it saved on.

The goals of the project:

  • Make a functioning GUI that automatically runs chkdsk after drive selections are made
  • Will log all output to a location specified by the user
  • Will give options to choose what options to add to chkdsk, /X /R /F being the three biggest ones.
  • An option to run in multiple passes.
Anyone that is willing to set aside some dedicated time to sit down, discuss best way to proceed, and help with programming will receive credit where due.

Oh and anyone looking to help with bug-testing is welcome as well :oops:

File attached, I had discovered a mockup I made originally as an example to show a possible layout.

checkthatdrive.au3

Edited by hackersarchangel

Share this post


Link to post
Share on other sites



I Suggest to be a tool is icon and when you press it directly appear gui associated devices that connected to it either hard disk or flash or external hard disk .also gui must to contain bottun for repair pation chkdsk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • mdwerne
      By mdwerne
      I'm attempting to cobble together a replacement for the 64bit version of BGInfo that will run within WinPE 10/64. I've located a couple useful threads:
       Between the two, they get me close (see code below), but for some reason GDI+ is not working the same within WinPE as it does in Windows 10. Bottomline is that the "Text" never get's written to WallPaper.
      Here is what I have thus far. Any thoughts if any of the GDI commands might not work within WinPE? Any other way to achieve the same result (system information on the wallpaper in WinPE 10)?
      #include <GDIPlus.au3> #include <Date.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\WallPaper.bmp") $imagegraphics = _GDIPlus_ImageGetGraphicsContext($image) $w = _GDIPlus_ImageGetWidth($image) $h = _GDIPlus_ImageGetHeight($image) $whitebrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $fontfamily = _GDIPlus_FontFamilyCreate("Arial") $font = _GDIPlus_FontCreate($fontfamily, 16) $stringformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($stringformat, 2) $rect = _GDIPlus_RectFCreate(0, $h - $h + 100, $w - 25, $h) ;$rect = _GDIPlus_RectFCreate(100, 100, 200, 200) _GDIPlus_GraphicsDrawStringEx($imagegraphics, _Now() & @CRLF & @UserName & @CRLF & @ComputerName & @CRLF & @IPAddress1, $font, $rect, $stringformat, $whitebrush) _GDIPlus_ImageSaveToFile($image, @ScriptDir & "\NewWallPaper.bmp") _GDIPlus_ImageDispose($image) _GDIPlus_GraphicsDispose($imagegraphics) _GDIPlus_BrushDispose($whitebrush) _GDIPlus_FontFamilyDispose($fontfamily) _GDIPlus_FontDispose($font) _GDIPlus_StringFormatDispose($stringformat) _GDIPlus_Shutdown() _ChangeDesktopWallpaper(@ScriptDir & "\NewWallPaper.bmp", 2) Func _ChangeDesktopWallpaper($bmp, $style = 0) ;=============================================================================== ; ; Function Name: _ChangeDesktopWallPaper ; Description: Update WallPaper Settings ; Usage: _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1) ; Parameter(s): $bmp - Full Path to BitMap File (*.bmp) ; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ; Author(s): FlyingBoz ; Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro ; Excalibur - Reawakening my interest in Getting This done. ; ;=============================================================================== If Not FileExists($bmp) Then Return -1 ;The $SPI* values could be defined elsewhere via #include - if you conflict, ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP = "HKEY_CURRENT_USER\Control Panel\Desktop" If $style = 1 Then RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0) Else RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style) EndIf DllCall("user32.dll", "int", "SystemParametersInfo", _ "int", $SPI_SETDESKWALLPAPER, _ "int", 0, _ "str", $bmp, _ "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) Return 0 EndFunc ;==>_ChangeDesktopWallpaper Thanks for your time,
      -Mike
    • doestergaard
      By doestergaard
      In one of my scripts, I needed to know, where Windows was installed at. I know there is several ways to this already, but I was thinking that I would share how I do it using WMI.
      If anyone has any suggestions or comment on the code, feel free to do so.
       
      Code:
      #include <File.au3> Local $STR_DRIVE = GetWindowsDrive() If @error Then MsgBox(@extended, "Result", "Unable to locate Windows", 0) Else MsgBox(@extended, "Result", "Windows is located at: " & $STR_DRIVE, 0) EndIf Exit Func GetWindowsDrive() Local $WMI_GET = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If Not IsObj($WMI_GET) Then Return SetError(1, 16, 0) Local $WMI_COL_DRIVES = $WMI_GET.ExecQuery("SELECT DeviceID FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'") For $WMI_DRIVE In $WMI_COL_DRIVES Local $WMI_COL_PARTITIONS = $WMI_GET.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $WMI_DRIVE.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition") For $WMI_PARTITION In $WMI_COL_PARTITIONS Local $WMI_COL_LOGICALDISKS = $WMI_GET.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $WMI_PARTITION.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition") For $WMI_LOGICALDISK In $WMI_COL_LOGICALDISKS If FileExists($WMI_LOGICALDISK.DeviceID & "\Windows\explorer.exe") Then Local $STR_RESULT = $WMI_LOGICALDISK.DeviceID EndIf Next Next Next $WMI_GET = 0 $WMI_COL_DRIVES = 0 $WMI_DRIVE = 0 $WMI_COL_PARTITIONS = 0 $WMI_PARTITION = 0 $WMI_LOGICALDISKS = 0 $WMI_LOGICALDISK = 0 Return SetError(0, 64, $STR_RESULT) EndFunc ; ==>GetWindowsDrive()  
    • guinness
      By guinness
      Source: https://en.wikipedia.org/wiki/TypeScript
       
      Site: http://www.typescriptlang.org/
    • MadDogVachon
      By MadDogVachon
      Hi everyone,
      Here is my script that does the job of the original BootSectGui. I wrote it because I needed a BootSectGui that works in WinPE x64 environment. The original works only in x86 envoronment. It is free to use, modify and distribute. I coded first in French and then in English, it may have some mistranslation.
      In the 7z attached file you have these files:
      BootSectGui - original - Main.png    ->  The original Main window of BootSectGui BootSectGui - original - Log.png     ->  The original Log window of BootSectGui BootSectGui - original.exe               ->  The original BooSectGui.exe program BootSectGui_x86_x64.au3              ->  My code BootSectGui_x86.exe                      ->  My program x86 version 1.3 BootSectGui_x64.exe                      ->  My program x64 version 1.3 BootSectGui_x86_x64 1.2.1.au3     ->  My code for 1.2.1 BootSectGui_x86 1.2.1.exe             ->  My program 1.2.1 x86 version
      BootSectGui_x64 1.2.1.exe             ->  My program 1.2.1 x64 version BootSectGui_x64 - Main.png          ->  My Main window
      BootSectGui_x64 - Log.png            ->  My Log window BootSectGui_x64 - Main 1.2.1.png  ->  My Main window 1.2.1
      BootSectGui.psd                             ->  My "code" for the ico files in Photoshop format BootSectGui BSG 64.ico                 ->  The icon used with my program, in 64 dots BootSectGui BSG 256.ico               ->  The same in 256 dots BootSectGui G BS 64.ico                ->  Another icon that looks more like the original one, in 64 dots BootSectGui G BS 256.ico              ->  The same in 256 dots Enjoy!
      MDV
      Here's the code:
      #RequireAdmin #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=BootSectGui BSG 64.ico #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Comment=New BootSectGui #AutoIt3Wrapper_Res_Description=New BootSectGui that works in WinPE x86 and x64 #AutoIt3Wrapper_Res_Fileversion=1.3 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3" #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: MadDogVachon Script Function: A Gui for BootSect that work in WinPE x64 environment (also in WinPE x86 and Windows x86 x64) Thanks to AZJIO for the improvement of my code! #ce ---------------------------------------------------------------------------- #include <GuiConstantsEx.au3> #include <Constants.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $Title = "BootSectGui - AutoIt3", $sPathBootSect, $sDriveSelectionItems, $sDriveSelectionFirst, $sBootCode, $sp ; GUI + ID Local $hBootSectGuiMain, $msg, $iSingleDrive, $iAllDrives, $iSYSDrive, $iNT60, $iNT52, $iMBRYesNo, $iForceYesNo, $iDriveSelection, $iBtnWrite, $iQuit If FileExists(@WorkingDir & "\bootsect.exe") Then $sPathBootSect = @WorkingDir & "\bootsect.exe" ElseIf FileExists(@ScriptDir & "\bootsect.exe") Then $sPathBootSect = @ScriptDir & "\bootsect.exe" ElseIf FileExists(@SystemDir & "\bootsect.exe") Then $sPathBootSect = @SystemDir & "\bootsect.exe" ElseIf FileExists(@WindowsDir & "\bootsect.exe") Then $sPathBootSect = @WindowsDir & "\bootsect.exe" Else MsgBox(16 + 262144, $Title, "The necessary 'BootSect.exe' file not found!" & @CRLF & @CRLF & "The program will end now!") Exit EndIf ;Main Menu $hBootSectGuiMain = GUICreate($Title, 525, 175) Local $GuiX = 18, $GuiY = 20 ; Group Drive(s) GUICtrlCreateGroup("Write master boot code into", $GuiX, $GuiY, 189, 130) $iAllDrives = GUICtrlCreateRadio("All Drives", $GuiX + 15, $GuiY + 20, 80) $iSingleDrive = GUICtrlCreateRadio("Single Drive:", $GuiX + 15, $GuiY + 45, 80) GUICtrlSetState(-1, $GUI_CHECKED) ; ================================= $sp = Chr(1) Opt("GUIDataSeparatorChar", $sp) $sDriveSelectionItems = _GetDrv() If Not $sDriveSelectionItems Then ; An error occurred when retrieving the drives. MsgBox(4096, $Title, "Error on querying drives" & @CRLF & @CRLF & "The program will end now!") Exit EndIf $sDriveSelectionFirst = StringRegExp($sDriveSelectionItems, '(?:\A|\001)([C-Z]: Fixed.*?)(?=\001)', 1) If @error Then $sDriveSelectionFirst = StringLeft($sDriveSelectionItems, StringInStr($sDriveSelectionItems & $sp, $sp) - 1) Else $sDriveSelectionFirst = $sDriveSelectionFirst[0] EndIf $iDriveSelection = GUICtrlCreateCombo("", $GuiX + 15, $GuiY + 70, 160, 25, $WS_VSCROLL + $CBS_DROPDOWNLIST) GUICtrlSetFont(-1, -1, -1, 0, "Courier New") GUICtrlSendMsg(-1, 0x160, 370, 0) GUICtrlSetData(-1, $sDriveSelectionItems, $sDriveSelectionFirst) ; ================================= $iSYSDrive = GUICtrlCreateRadio("System Drive", $GuiX + 15, $GuiY + 95, 80) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $GuiX += 205 ; Group Windows version GUICtrlCreateGroup("Select master boot code version", $GuiX, $GuiY, 185, 80) $iNT60 = GUICtrlCreateRadio("Windows Vista/7/8 ""/NT60""", $GuiX + 15, $GuiY + 20, 160) GUICtrlSetState(-1, $GUI_CHECKED) $iNT52 = GUICtrlCreateRadio("Windows XP ""/NT52""", $GuiX + 15, $GuiY + 45, 130) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $GuiX += 200 ; Group Master Boot Record GUICtrlCreateGroup("Options", $GuiX, $GuiY, 85, 80) $iMBRYesNo = GUICtrlCreateCheckbox("MBR", $GuiX + 15, $GuiY + 20, 60) GUICtrlSetState(-1, $GUI_CHECKED) $iForceYesNo = GUICtrlCreateCheckbox("Force", $GuiX + 15, $GuiY + 45, 60) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group ; Group Button Local $ButtonX = 18 + 205 + 17, $ButtonY = $GuiY + 95 $iBtnWrite = GUICtrlCreateButton("Write master boot code", $ButtonX, $ButtonY, 150, 40) $iQuit = GUICtrlCreateButton("Quit", $ButtonX + 183, $ButtonY, 85, 40) GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button GUISetState() ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $iBtnWrite If GUICtrlRead($iNT60) = $GUI_CHECKED Then $sBootCode = "/NT60" ElseIf GUICtrlRead($iNT52) = $GUI_CHECKED Then $sBootCode = "/NT52" EndIf If GUICtrlRead($iSingleDrive) = $GUI_CHECKED Then BootSectLog(StringLeft(GUICtrlRead($iDriveSelection), 2)) ElseIf GUICtrlRead($iAllDrives) = $GUI_CHECKED Then BootSectLog("All") Else BootSectLog("SYS") EndIf Case $iSingleDrive GUICtrlSetState($iDriveSelection, $GUI_ENABLE) Case $iAllDrives, $iSYSDrive GUICtrlSetState($iDriveSelection, $GUI_DISABLE) Case $GUI_EVENT_CLOSE, $iQuit Exit EndSwitch WEnd Func BootSectLog($sBootSectDrive) Local $hBootSectGuiLog, $iPID, $sBootSectInProgress, $iBootSectLog, $sLine, $iWidth = 530, $iHeight = 330, $iClose, $sMBR, $sForce If GUICtrlRead($iMBRYesNo) = $GUI_CHECKED Then $sMBR = " /mbr" If GUICtrlRead($iForceYesNo) = $GUI_CHECKED Then $sForce = " /force" $iPID = Run(@ComSpec & ' /c "' & $sPathBootSect & '" ' & $sBootCode & " " & $sBootSectDrive & $sMBR & $sForce, @ScriptDir, @SW_HIDE, $STDOUT_CHILD) $sBootSectInProgress = "Executing:" & @CRLF & " Bootsect " & $sBootCode & " " & $sBootSectDrive & $sMBR & $sForce & @CRLF & @CRLF & "--------------------------------------------------------------------------------" GUISetState(@SW_DISABLE, $hBootSectGuiMain) $hBootSectGuiLog = GUICreate("BootSect Log", $iWidth, $iHeight, -1, -1, $WS_CAPTION + $WS_SYSMENU + $WS_POPUP, -1, $hBootSectGuiMain) $iBootSectLog = GUICtrlCreateEdit($sBootSectInProgress, 2, 2, $iWidth, $iHeight - 60) $iClose = GUICtrlCreateButton("Close", $iWidth / 2 - 148, $iHeight - 38, 295, 30) GUICtrlSetState(-1, $GUI_DISABLE) ; Disable "Close" button GUISetState(@SW_SHOW, $hBootSectGuiLog) _GUICtrlEdit_AppendText($iBootSectLog, @CRLF) ; Add space While 1 $sLine = StdoutRead($iPID) If @error Then ExitLoop If $sLine Then _GUICtrlEdit_AppendText($iBootSectLog, @CRLF & $sLine) WEnd _GUICtrlEdit_AppendText($iBootSectLog, @CRLF & "--------------------------------------------------------------------------------" & @CRLF & @CRLF & "Bootsect has terminated itself") GUICtrlSetState($iClose, $GUI_ENABLE) ; Enable "Close" button While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $iClose Then GUISetState(@SW_ENABLE, $hBootSectGuiMain) GUIDelete($hBootSectGuiLog) ExitLoop EndIf WEnd EndFunc ;==>BootSectLog Func _GetDrv() Local $sInfo = _ComboListDrive('Fixed') $sInfo &= _ComboListDrive('Removable') Return StringTrimLeft($sInfo, 1) EndFunc ;==>_GetDrv Func _ComboListDrive($Type) ; coded by AZJIO (2013.01.26) Local $aDrive = DriveGetDrive($Type), $list = '', $sString, $sLabel If @error Then Return '' If $Type = 'Removable' Then $Type = 'Rem' For $i = 1 To $aDrive[0] If $aDrive[$i] = 'A:' Then ContinueLoop $sLabel = DriveGetLabel($aDrive[$i]) If StringLen($sLabel) > 15 Then $sLabel = StringLeft($sLabel, 12) & '...' $sString = StringFormat("%-2s %-5s %-15s %-5s ", StringUpper($aDrive[$i]), $Type, $sLabel, _ DriveGetFileSystem($aDrive[$i])) & _GetSize(DriveSpaceTotal($aDrive[$i])) & ' Gb' $list &= $sp & $sString Next Return $list EndFunc ;==>_ComboListDrive Func _GetSize($s) ; coded by AZJIO $s = StringFormat('%.03f', $s / 1024) If StringLen($s) > 7 Then $s = StringRegExpReplace(StringTrimRight($s, 4), '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1 ') & StringRight($s, 4) Return StringFormat('%9s', $s) ; 9 ???????? EndFunc ;==>_GetSize - - - - -
      Edit 1: Corrected mistype in topic title, updated code with JFX recommendation and updated BootSectGui_x64 - Main.png with the new code. Version 1.1
      Edit 2: Added /mbr (by default). Corrected the line to execute bootsect.exe using the variable $BootSect. Version 1.1.1
      Edit 3: Added /force. Corrected a bug when not founding boosect.exe. Added SYS (system drive) in the list. Updated BootSectGui_x64 - Main.png, BootSectGui_x64 - Log.png and exe files. Version 1.2
      Edit 4: Added improvement by AZJIO and updated files. Version 1.3
      Edit 5: Little update of code added version 1.2.1 with improvement of AZJIO and a simple list of drives.
      BootSectGui_x64.7z