史萊姆論壇

返回   史萊姆論壇 > 教學文件資料庫 > 應用軟體使用技術文件
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


 
 
主題工具 顯示模式
舊 2006-04-04, 03:42 PM   #1
psac
榮譽會員
 
psac 的頭像
榮譽勳章
UID - 3662
在線等級: 級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時級別:30 | 在線時長:1048小時 | 升級還需:37小時
註冊日期: 2002-12-07
住址: 木柵市立動物園
文章: 17381
現金: 5253 金幣
資產: 33853 金幣
預設 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

_____________________________@
__________________
http://bbsimg.qianlong.com/upload/01/08/29/68/1082968_1136014649812.gif
psac 目前離線  
送花文章: 3, 收花文章: 1631 篇, 收花: 3205 次
 



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 05:58 AM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1