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