|
| 1 | +#RequireAdmin |
| 2 | +#AutoIt3Wrapper_Run_AU3Check=Y |
| 3 | +#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y |
| 4 | +#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 |
| 5 | +#Tidy_Parameters=/reel |
| 6 | + |
| 7 | +#include <GUIConstantsEx.au3> |
| 8 | +#include <GuiListView.au3> |
| 9 | +#include <MsgBoxConstants.au3> |
| 10 | +#include <WindowsConstants.au3> |
| 11 | +#include "..\NetWebView2Lib.au3" |
| 12 | + |
| 13 | +; RegCleaner.au3 |
| 14 | + |
| 15 | +Global $_g_s_ELEMENTs = '' |
| 16 | + |
| 17 | +_Cleaner() |
| 18 | + |
| 19 | +Func _Cleaner() |
| 20 | + ConsoleWrite("! MicrosoftEdgeWebview2 : version check: " & _NetWebView2_IsAlreadyInstalled() & ' ERR=' & @error & ' EXT=' & @extended & @CRLF) |
| 21 | + |
| 22 | + ; === Configuration === |
| 23 | + Local $sSearchTerm = "NetWebView2Lib" ; NetWebView2Lib |
| 24 | + Local $aTargets[2] = ["HKEY_LOCAL_MACHINE64\SOFTWARE\Classes", "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes"] |
| 25 | + |
| 26 | + ; GUICreate |
| 27 | + Local $iWidth = @DesktopWidth * 0.7, $iHeight = @DesktopHeight * 0.9 |
| 28 | + Local $hGUI = GUICreate("NetWebView2 - Registry Deep Cleaner", $iWidth, $iHeight) |
| 29 | + #forceref $hGUI |
| 30 | + |
| 31 | + GUISetFont(9, 400, 0, "Segoe UI") |
| 32 | + $iWidth -= 20 |
| 33 | + $iHeight -= 90 |
| 34 | + Local $idListView = GUICtrlCreateListView("Registry Key Path|Details", 10, 10, $iWidth, $iHeight, $LVS_REPORT + $LVS_SHOWSELALWAYS) |
| 35 | + _GUICtrlListView_SetExtendedListViewStyle($idListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) |
| 36 | + _GUICtrlListView_SetColumnWidth($idListView, 0, $iWidth * 0.6) |
| 37 | + _GUICtrlListView_SetColumnWidth($idListView, 1, $iWidth * 0.4) |
| 38 | + $iHeight += 20 |
| 39 | + Local $idStatus = GUICtrlCreateLabel("Scanning registry... please wait...", 10, $iHeight, $iWidth - 210 - 10, 20) |
| 40 | + $iHeight += 20 |
| 41 | + Local $idBtnCancel = GUICtrlCreateButton("Cancel", $iWidth - 100, $iHeight, 100, 40) |
| 42 | + Local $idBtnDelete = GUICtrlCreateButton("Delete Selected", $iWidth - 210, $iHeight, 100, 40) |
| 43 | + GUISetState(@SW_SHOW) |
| 44 | + |
| 45 | + ; Scan |
| 46 | + Local $iTotalFound = 0 |
| 47 | + Local $bCanceled = False |
| 48 | + For $sRoot In $aTargets |
| 49 | + __Registry_Scan_Recursive($sRoot, $sSearchTerm, $idListView, $iTotalFound, $idStatus, $idBtnCancel) |
| 50 | + If @error Then |
| 51 | + $bCanceled = True |
| 52 | + ExitLoop |
| 53 | + EndIf |
| 54 | + Next |
| 55 | + If $bCanceled = True Then |
| 56 | + GUICtrlSetData($idStatus, "Scan canceled. Found " & $iTotalFound & " keys.") |
| 57 | + Else |
| 58 | + GUICtrlSetData($idStatus, "Scan complete. Found " & $iTotalFound & " keys.") |
| 59 | + EndIf |
| 60 | + |
| 61 | + ConsoleWrite($_g_s_ELEMENTs & @CRLF) |
| 62 | + |
| 63 | + |
| 64 | + While 1 |
| 65 | + Switch GUIGetMsg() |
| 66 | + Case $GUI_EVENT_CLOSE |
| 67 | + Exit |
| 68 | + |
| 69 | + Case $idBtnDelete |
| 70 | + Local $iCheckedCount = 0 |
| 71 | + ; Count checked items first |
| 72 | + For $i = 0 To _GUICtrlListView_GetItemCount($idListView) - 1 |
| 73 | + If _GUICtrlListView_GetItemChecked($idListView, $i) Then $iCheckedCount += 1 |
| 74 | + Next |
| 75 | + |
| 76 | + If $iCheckedCount = 0 Then |
| 77 | + MsgBox($MB_ICONEXCLAMATION, "Nothing selected", "Please check the keys you want to remove.") |
| 78 | + ContinueLoop |
| 79 | + EndIf |
| 80 | + |
| 81 | + If MsgBox($MB_YESNO + $MB_ICONWARNING, "Confirm Deletion", "Are you sure you want to delete the " & $iCheckedCount & " selected keys?") = $IDYES Then |
| 82 | + __Delete_Checked_Items($idListView) |
| 83 | + MsgBox($MB_ICONINFORMATION, "Done", "Cleanup finished successfully.") |
| 84 | + Exit |
| 85 | + EndIf |
| 86 | + EndSwitch |
| 87 | + WEnd |
| 88 | + |
| 89 | +EndFunc ;==>_Cleaner |
| 90 | + |
| 91 | +;--------------------------------------------------------------------------------------- |
| 92 | +Func __Registry_Scan_Recursive($sKey, $sSearch, $hLV, ByRef $iCount, $idStatus, $idBtnCancel) |
| 93 | + Local $iIndex = 1 |
| 94 | + While 1 |
| 95 | + Local $sSubKey = RegEnumKey($sKey, $iIndex) |
| 96 | + If @error Then ExitLoop |
| 97 | + |
| 98 | + If Mod($iIndex, 100) = 0 Then |
| 99 | + GUICtrlSetData($idStatus, "Scanning: " & $iIndex & " keys in " & StringLeft($sKey, 40) & "...") |
| 100 | + If GUIGetMsg() = $idBtnCancel Then Return SetError(1) |
| 101 | + EndIf |
| 102 | + |
| 103 | + Local $sFull = $sKey & "\" & $sSubKey |
| 104 | + Local $sData = RegRead($sFull, "") |
| 105 | + |
| 106 | + If StringInStr($sSubKey, $sSearch) Or StringInStr($sData, $sSearch) Then |
| 107 | + $iCount += 1 |
| 108 | + Local $sDisplayData = ($sData <> "" ? $sData : "Folder/Container") |
| 109 | + Local $s_ELEMENT = $sFull & "|" & $sDisplayData |
| 110 | + $_g_s_ELEMENTs &= $sFull & "|" & $sDisplayData & @CRLF |
| 111 | + GUICtrlCreateListViewItem($s_ELEMENT, $hLV) |
| 112 | + _GUICtrlListView_SetItemChecked($hLV, _GUICtrlListView_GetItemCount($hLV) - 1) |
| 113 | + EndIf |
| 114 | + |
| 115 | + __Registry_Scan_Recursive($sFull, $sSearch, $hLV, $iCount, $idStatus, $idBtnCancel) |
| 116 | + If @error Then Return SetError(1) |
| 117 | + |
| 118 | + $iIndex += 1 |
| 119 | + WEnd |
| 120 | +EndFunc ;==>__Registry_Scan_Recursive |
| 121 | + |
| 122 | +;--------------------------------------------------------------------------------------- |
| 123 | +Func __Delete_Checked_Items($hLV) |
| 124 | + ; backwards deletion to avoid index shifting |
| 125 | + For $i = _GUICtrlListView_GetItemCount($hLV) - 1 To 0 Step -1 |
| 126 | + If _GUICtrlListView_GetItemChecked($hLV, $i) Then |
| 127 | + Local $sKeyPath = _GUICtrlListView_GetItemText($hLV, $i) |
| 128 | + If RegDelete($sKeyPath) Then |
| 129 | + ConsoleWrite("[-] Deleted: " & $sKeyPath & @CRLF) |
| 130 | + EndIf |
| 131 | + EndIf |
| 132 | + Next |
| 133 | +EndFunc ;==>__Delete_Checked_Items |
| 134 | +;--------------------------------------------------------------------------------------- |
0 commit comments