• 欢迎访问奇跡の海网站,本站不上传任何资源,所有资源均来自于网络,欢迎加入奇跡の海~!奇跡の海-WordPress QQ群
  • 本站下载资源为网络上收集整理而来,并且以计算机技术研究交流为目的,版权归原作者所有,仅供大家参考,学习,不存在任何商业目的与商业用途.
  • 本站系统镜像均来自于官方原版,ed2k可视为P2P下载链接。所有操作系统默认均为试用版,如有正版密钥可以有效激活,本站不提供任何激活和相关服务。

AutoIt3(au3)源码-全盘扫描XXX文件并读取

AutoIT3 奇跡の海 2年前 (2017-11-09) 574次浏览 已收录 0个评论 扫描二维码

代码简介

AutoIt3(au3)源码-全盘扫描XXX文件并读取
全盘扫描XXX文件并读取,如果硬盘或者移动硬盘里的文件夹数量很多的话,时间会超。最好别超过2层目录,不接移动硬盘全盘扫描不包括c盘为3秒左右

Au3源码

#include <GuiListView.au3>
#include <File.au3>
#NoTrayIcon
#RequireAdmin
#Region ### START Koda GUI section ### Form=E:\ImageXdism\Form1.kxf
Global $help = FileRead(@ScriptDir & "\AppxPackage.txt")
Global $WinDism = @WindowsDir & '\system32\dism.exe', $BCDBOOT = @ScriptDir & '\BCDBoot\bcdboot.exe', $BOOTSECT = @ScriptDir & '\BCDBoot\bootsect.exe'
$Form1 = GUICreate("Form1", 360, 399, -1, -1)
$Tab1 = GUICtrlCreateTab(0, 0, 353, 393)
$TabSheet1 = GUICtrlCreateTabItem("恢复")
$Group1 = GUICtrlCreateGroup("", 8, 24, 337, 305)
$ListView1 = GUICtrlCreateListView("镜像", 12, 34, 329, 289, 0x5001000D, 0x00010321)
GUICtrlSendMsg($ListView1, 4126, 0, 325)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Combo1 = GUICtrlCreateCombo("", 80, 336, 65, 25, 2105411);2105411=BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_UPPERCASE)
$Combo2 = GUICtrlCreateCombo("", 80, 360, 65, 25, 2105411);2105411=BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_UPPERCASE)
$Label1 = GUICtrlCreateLabel("引导分区:", 8, 336, 64, 17)
$Label2 = GUICtrlCreateLabel("系统分区:", 7, 360, 64, 17)
$Checkbox1 = GUICtrlCreateCheckbox("检查镜像", 152, 336, 73, 17)
$Checkbox2 = GUICtrlCreateCheckbox("校验镜像", 152, 360, 73, 17)
$Button1 = GUICtrlCreateButton("执行", 224, 336, 57, 41)
$Button2 = GUICtrlCreateButton("刷新", 287, 336, 57, 41)
$TabSheet2 = GUICtrlCreateTabItem("帮助")
$Group2 = GUICtrlCreateGroup("", 8, 24, 337, 361)
$Edit1 = GUICtrlCreateEdit("", 12, 34, 329, 345, 0x50201844, 0x00000200)
GUICtrlSetData($Edit1, $help)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
GUICtrlSetData($Combo1, WmiDriveGet(), StringLeft(WmiDriveGet(), 2))
GUICtrlSetData($Combo2, WmiDriveGet(), StringLeft(WmiDriveGet(), 2))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Button1
                        Local $index = _GUICtrlListView_GetItemText($ListView1, 0);读取指定行
                        Local $ItemCount = _GUICtrlListView_GetNextItem($ListView1);读取选中行数
                        Local $ItemCounAll = _GUICtrlListView_GetItemCount($ListView1) ;行总数
                        If StringLeft(GUICtrlRead($Combo2), 2) = StringLeft($index, 2) Then
                                MsgBox(0, '提示', '系统分区不能和镜像分区同一目录')
                        Else
                                MsgBox(0, StringLeft($index, 2), _GUICtrlListView_GetItemText($ListView1, $ItemCount))
                        EndIf
                Case $Button2
                        WimGetall()
        EndSwitch
WEnd

Func WimGetall()
        Local $hTimer = TimerInit() ;
        _GUICtrlListView_DeleteAllItems($ListView1)
        Local $DriveGet = StringSplit(StringTrimRight(WmiDriveGet(), 1), '|')
        Local $Drive = ''
        For $t = 1 To $DriveGet[0]
                If Not FileExists($DriveGet[$t]& "\Windows") And _
         Not FileExists($DriveGet[$t]& "\Users") Then 
                $Drive &= $DriveGet[$t] & '\|';'d:\|e:\|f:\|g:\'
                EndIf                
        Next
        Local $DriveAll = StringLower(StringTrimRight($Drive, 1))
        $sFiles = _FileListEx($DriveAll)
        $aFiles = StringSplit($sFiles, "|")
        For $i = 1 To $aFiles[0]
                        SysListView32($aFiles[$i])                
        Next
        _GUICtrlListView_EndUpdate($ListView1)
        Local $fDiff = TimerDiff($hTimer)
MsgBox(0, "Time Difference", Int($fDiff/1024))

EndFunc   ;==>WimGetall

Func SysListView32($driwim)
        ;_GUICtrlListView_BeginUpdate($ListView1)
        Local $sFilePath = @TempDir & '\wiminfo.txt'
        FileDelete($sFilePath)
        if FileGetSize($driwim) >= "1000000000" Then
        RunWait(@ComSpec & ' /C ' & '@echo off &' & $WinDism & ' /Get-ImageInfo /imagefile:"' & $driwim & '" >' & $sFilePath, @WindowsDir & '\system32', @SW_HIDE)
        EndIf
        $wimtxt = FileRead($sFilePath)
        Local $index = StringRegExp($wimtxt, '索引: (\V+)', 3)
        Local $name = StringRegExp($wimtxt, '名称: (\V+)', 3)
        if FileGetSize($driwim) >= "1000000000" Then _GUICtrlListView_AddItem($ListView1, $driwim & '(' & ByteSuffix(FileGetSize($driwim)) & ')')
        For $i = 0 To UBound($name) - 1
                _GUICtrlListView_AddItem($ListView1, '       [' & $index[$i] & '] ' & $name[$i])
        Next
        FileDelete($sFilePath)
        GUICtrlSendMsg($ListView1, 4126, 0, 325);4126=$LVM_SETCOLUMNWIDTH
        _GUICtrlListView_JustifyColumn($ListView1, 0, 0)
EndFunc   ;==>SysListView32

Func ByteSuffix($iBytes)
        Local $iIndex = 0, $aArray = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
        While $iBytes > 1023
                $iIndex += 1
                $iBytes /= 1024
        WEnd
        Return StringLeft($iBytes, 4) & $aArray[$iIndex]
EndFunc   ;==>ByteSuffix


Func WmiDriveGet()
        Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
        Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
        If Not IsObj($colItems) Then Exit
        Local $sAll = ''
        For $objItem In $colItems
                Local $iFileSize = DriveSpaceTotal($objItem.DeviceID)
                Local $DriveSize = Int($iFileSize / 1024)
                If $DriveSize >= 15 Then $sAll &= $objItem.DeviceID & '|'
        Next
        Return $sAll ;c:|d:|e:|f:|g:|
EndFunc   ;==>WmiDriveGet


Func _FileListEx($sDir)
        Local $aDir = StringSplit($sDir, "|", 2)
        For $x = 0 To $aDir[0]
                If StringInStr(FileGetAttrib($aDir[$x]), "D") = 0 Then Return SetError(1, 0, "")
        Next
        Local $oFSO = ObjCreate("Scripting.FileSystemObject")
        Local $objDir
        Local $iCnt = 0
        Local $sFiles = ""
        Do
                $objDir = $oFSO.GetFolder($aDir[$iCnt])
                For $aItem In $objDir.SubFolders
                        ;文件夹层数可以通过 StringReplace($aItem.Path, "\", "", 0, 1)的@extended值来判断
                        Local $sString = StringReplace($aItem.Path, "\", "", 0, 1)                        Local $iReplacements = @extended
                        ;扩展应用改下这句, 如指定文件夹 If StringInStr($aItem.Name, "XXX") Then
                        If Not StringInStr($aItem.Path, "System Volume Information") And Not StringInStr($aItem.Path, "$RECYCLE.BIN") _
                                        And $iReplacements <= 2  Then $sDir &= "|" & $aItem.Path
                Next
                For $aItem In $objDir.Files
                        If StringRight($aItem.Name, 3) = "wim"  Then $sFiles &= $aItem.Path & "|" ;$sFiles &= $aItem.Path & "|"\
                Next
                $iCnt += 1
                If UBound($aDir) <= $iCnt Then $aDir = StringSplit($sDir, "|", 2)
        Until UBound($aDir) <= $iCnt
        If $sFiles Then $sFiles = StringTrimRight($sFiles, 1);去掉最右边"|"
        Return $sFiles
EndFunc   ;==>_FileListEx

版权声明:本站所有文章和资源使用CC BY-NC-SA 4.0协议授权发布 , 转载应当以相同方式注明文章来自“SeaOMC.COM->AutoIt3(au3)源码-全盘扫描XXX文件并读取!在下边可以分享本文哦!
喜欢 (0)
[]
分享 (0)
奇跡の海
关于作者:
一个WordPress菜鸟!
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址