找回密码
 加入
搜索
查看: 2025|回复: 3

[AU3基础] 达人们 帮忙看看 这个自动卸载硬件信息的脚本 错在哪里?

[复制链接]
发表于 2012-5-9 12:43:46 | 显示全部楼层 |阅读模式
本帖最后由 yngwcc 于 2012-5-9 12:52 编辑

我是新手 照着写的 不知道错在哪里? 谢谢
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Array.au3>
;_DrvUnins_ReadHwinds()
;_DrvUnins_TidyHwids()
;_DrvUnins_Unins()

Func _DrvUnins_ReadHwinds()
        Local $HwidList[1][2],$p = 1
        Local $RootKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum"
        Local $i = 1
        While 1
                Local $SubKey1 = RegEnumKey($RootKey,$i)
                If @error = -1 Then ExitLoop
                $SubKey1 = $RootKey & "\" & $SubKey1
                Local $j = 1
                While 1
                        Local $SubKey2 = RegEnumKey($SubKey1,$j)
                        If @error = -1 Then ExitLoop
                        $SubKey2 = $SubKey1 & "\" & $SubKey2
                        Local $k = 1
                        While 1
                                Local $SubKey3 = RegEnumKey($SubKey2,$k)
                                If @error = -1 Then ExitLoop
                                $SubKey3 = $SubKey2 & "\" & $SubKey3
                                Local $CLs = RegRead($SubKey3,"Class")
                                If $CLs <> "Mouse" And _
                                        $CLs <> "Keyboard" And _
                                        $CLs <> "System" And _
                                        $CLs <> "LegacyDriver" And _
                                        $CLs <> "Computer" And _
                                        $CLs <> "" Then
                                        ReDim $HwidList[$p + 1][2]
                                        $HwidList[$p][0] = $SubKey3
                                        $HwidList[$p][1] = RegRead($SubKey3,"HardwareID")
                                        $p += 1
                                EndIf
                                $k += 1
                        WEnd
                        $j += 1
                WEnd
                $i += 1
        WEnd
        Return $HwidList
EndFunc

Func _DrvUnins_TidyHwids($HwidList)
        Local $tHwidList[1],$tp = 1
        Local $i
        For $i = 1 To UBound($HwidList,1) - 1
                Local $Hwids = $HwidList[$i][1]
                If $Hwids <> "" Then
                        Local $tArr = StringSplit($Hwids,@LF)
                        If IsArray($tArr) And $tArr[0] > 1 Then
                                Local $j
                                For $j = 1 To UBound($tArr) - 1
                                        ReDim $tHwidList[$tp + 1]
                                        $tHwidList[$tp] = $tArr[$j]
                                        $tp += 1
                                Next
                        EndIf
                EndIf
        Next
        _ArrayDisplay($tHwidList)
        Local $i, $j
        For $i = 1 To UBound($tHwidList) - 2
                For $j = $i + 1 To UBound($tHwidList) - 1
                        If $tHwidList[$i] <> "" And _
                                $tHwidList[$i] = $tHwidList[$j] Then
                                $HwidList[$j] = ""
                        EndIf
                Next
        Next
        ;_ArrayDisplay($HwidList)
        Local $Hwids[1],$p = 1
        Local $i
        For $i = 1 To UBound($tHwidList) - 1
                If $tHwidList[$i] <> "" Then
                        ReDim $Hwids[$p + 1]
                        $Hwids[$p] = $tHwidList[$i]
                        $p += 1
                EndIf
        Next
        ;_ArrayDisplay($Hwids)
        Return $Hwids
EndFunc

Func _DrvUnins_Unins($Hwids)
        ProgressOn("驱动卸载","正在卸载驱动...")
        Local $i
        Local $Max = UBound($Hwids) - 1
        Local $per = 1
        For $i = 1 To $Max
                $per = Int($i / $Max * 100)
                ProgressSet($per,StringReplace($Hwids[$i],"&","&&"),"正在卸载驱动...(" & $per & "%)")
                RunWait("devcon.exe" & " remove " & $Hwids[$i],"",@SW_SHOW)
        Next
        ProgressOff()
EndFunc
 楼主| 发表于 2012-5-9 13:01:53 | 显示全部楼层
我已经找到原始代码 谢谢
http://www.autoitx.com/thread-23306-1-1.html
发表于 2012-6-22 22:41:35 | 显示全部楼层
这不是skyfree写的吗??
发表于 2012-6-26 07:45:21 | 显示全部楼层
就是SKYFREE写的 学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-20 13:36 , Processed in 0.087787 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表