|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
2006-04-04, 03:42 PM | #1 |
榮譽會員
|
KBClean - 清除KBUninstall目錄和註冊表項
簡陋的一個小東西
Windows update 會自動幫我們更新一些修正檔 預設值情況下這些 KBxxxxxx 或者 Qxxxxxx 會在 windows 目錄下和註冊表留下一些東西 一般情況下我們不需要去卸載這些修正檔(如果要卸載,可去 控制台->增加移除程式) 這個小工具會讀註冊表裡面的卸載項 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 得到相應的目錄,然後詢問用戶是否要清除目錄和註冊表項 用戶驗證之後會進行清除動作,清除完成之後在 控制台->增加移除程式裡面 也看不到了 看情況決定會不會再更新 謝謝使用 貼源碼,源碼也可以從 exe 文件裡面 de-compile 出來,沒密碼 代碼: #include <_mymsg.au3> #include <Array.au3> Global $header = "KBClean " Global $version = "V0.1.0" Dim $keyroot = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' Dim $keyname = 'UninstallString' Dim $akeys[1] Dim $index If MsgQuestion($header & $version, "Are you sure you want to delete the KBUninstall DIRs and these components in registry?") = 0 Then MsgInfo($header & $version, "Program exit...") Exit EndIf ; Get KB List GetKBList(); ;_ArrayDisplay($akeys, "KBList") ; Clean each KB For $index = 0 To UBound($akeys) - 1 If $akeys[$index] <> "" Then CleanKB($akeys[$index]) EndIf Next ; ; ; Func GetKBList() Local $i For $i = 1 To 100 Local $subkey = RegEnumKey($keyroot, $i) If @error Then ExitLoop ; If key found, record it. If StringLeft($subkey, 2) == "KB" AND StringIsDigit(StringMid($subkey, 3, 6)) Then _ArrayAdd($akeys, $subkey) EndIf If StringLeft($subkey, 1) == "Q" AND StringIsDigit(StringMid($subkey, 2, 6)) Then _ArrayAdd($akeys, $subkey) EndIf Next EndFunc Func CleanKB($kbname) Local $dirname = "" $dirname = GetDir(RegRead($keyroot & "\" & $kbname, $keyname)) If $dirname <> "" AND FileExists($dirname) Then If MsgQuestion($header & $version, "Delete " & $dirname & " ?") = 1 Then If DirRemove($dirname, 1) Then RegDelete($keyroot & "\" & $kbname) EndIf EndIf EndIf EndFunc ;"C:\WINNT\xxx\spuninst\spuninst.exe" Func GetDir($fullpath) Local $res = "" Local $pos $pos = StringInStr($fullpath, "\", 0, 3) If $pos > 10 Then $res = StringLeft($fullpath, $pos) If StringInStr($res, " ") > 1 Then $res = "" EndIf Else $res = "" EndIf Return $res EndFunc所上傳文件 KBClean.rar (120.0 KB, 14 次點擊) vbs有現成的 remove_hotfix.vbs If MsgBox("This program will now remove uninstall folders.", _ vbOkCancel, "Uninstall Remover") = vbOk Then Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") sWinDir = oFSO.GetSpecialFolder(0) Set oFolder = oFSO.GetFolder(sWinDir) Set oDictionary = CreateObject("Scripting.Dictionary") For Each oSubFolder In oFolder.SubFolders sFolderName = LCase(oSubFolder.Name) sFolderPath = LCase(oSubFolder.Path) If Left(sFolderName, 13) = "$ntuninstallq" _ Or Left(sFolderName, 14) = "$ntuninstallkb" Then ' Get the update name for the registry delete: sUpdateName = Mid(sFolderName, 13, Len(sFolderName) - 13) ' Never delete folders/files while enumerating a file/folder collection. ' Adds them to a dictionary object for later handling instead: oDictionary.Add sUpdateName, sFolderPath End If Next sDeleted = "" For Each sUpdateName In oDictionary.Keys sDeleted = sDeleted & vbCrLf & sUpdateName sFolderPath = oDictionary.Item(sUpdateName) On Error Resume Next ' Remove entry in Add/Remove Programs: oShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\" _ & "CurrentVersionUninstall" & sUpdateName & "" On Error Goto 0 ' Delete the unisntall folder: oShell.Run "%Comspec% /C RD /S /Q " _ & Chr(34) & sFolderPath & Chr(34), 0, True Next If sDeleted <> "" Then MsgBox "The uninstall data for the following updates has been removed:" _ & vbCrLf & UCase(sDeleted) Else MsgBox "No update uninstall data found." End If End If _____________________________@ |
__________________ |
|
送花文章: 3,
|