Skip to content

Commit 4647da5

Browse files
authored
v1.4.0
Due to changes in the COM Dispatch IDs (DispIds) for better organization, it is highly recommended to run the included RegCleaner.au3 before registering the new version. This ensures that any stale registry entries from previous builds are purged, preventing "Object action failed" errors
1 parent 56f6de0 commit 4647da5

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

bin/RegCleaner.au3

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#RequireAdmin
2+
#include <GUIConstantsEx.au3>
3+
#include <WindowsConstants.au3>
4+
#include <GuiListView.au3>
5+
#include <MsgBoxConstants.au3>
6+
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, 80)
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
59+
60+
;---------------------------------------------------------------------------------------
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
66+
67+
If Mod($iIndex, 100) = 0 Then
68+
GUICtrlSetData($idStatus, "Scanning: " & $iIndex & " keys in " & StringLeft($sKey, 40) & "...")
69+
EndIf
70+
71+
Local $sFull = $sKey & "\" & $sSubKey
72+
Local $sData = RegRead($sFull, "")
73+
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
80+
81+
_Registry_Scan_Recursive($sFull, $sSearch, $hLV, $iCount)
82+
$iIndex += 1
83+
WEnd
84+
EndFunc
85+
;---------------------------------------------------------------------------------------
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
97+
;---------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)