150 lines
5.1 KiB
AutoIt
150 lines
5.1 KiB
AutoIt
|
#NoTrayIcon
|
||
|
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||
|
#AutoIt3Wrapper_Outfile_x64=FileList.exe
|
||
|
#AutoIt3Wrapper_UseUpx=y
|
||
|
#AutoIt3Wrapper_UseX64=y
|
||
|
#AutoIt3Wrapper_Change2CUI=y
|
||
|
#AutoIt3Wrapper_Res_Comment=Summary File List Of Specified Folders
|
||
|
#AutoIt3Wrapper_Res_Description=Summary File List Of Specified Folders
|
||
|
#AutoIt3Wrapper_Res_Fileversion=1.2.0.0
|
||
|
#AutoIt3Wrapper_Res_ProductVersion=1.2.0.0
|
||
|
#AutoIt3Wrapper_Res_LegalCopyright=TE / Vayne Tan
|
||
|
#AutoIt3Wrapper_Res_Language=1033
|
||
|
#AutoIt3Wrapper_Res_Field=CompanyName|Wistron InfoComm (Chongqing) Co., Ltd.
|
||
|
#AutoIt3Wrapper_Res_Field=ProductName|FileList.exe
|
||
|
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
|
||
|
;Change History
|
||
|
;1.1.0.0 Add check ping result of each hosts.
|
||
|
;1.2.0.0 Fixed an array out of bounds issue.
|
||
|
;#AutoIt3Wrapper_Icon=App.ico
|
||
|
|
||
|
#Include <File.au3>
|
||
|
#Include <String.au3>
|
||
|
|
||
|
Global $gSRC = @ScriptDir, $gTYP = 0, $gFTR = '*||', $gOUT = @ScriptDir&'\Result.txt'
|
||
|
Global $IniFile = StringTrimRight(@ScriptName, 4) & '.ini'
|
||
|
Global $gUSR = IniRead($IniFile, 'Settings', 'DefaultUser', 'Administrator')
|
||
|
Global $gPWD = IniRead($IniFile, 'Settings', 'DefaultPassword', 'CASPER')
|
||
|
Global $Configs = IniReadSectionNames($IniFile)
|
||
|
|
||
|
|
||
|
__Main__()
|
||
|
|
||
|
Func __Main__()
|
||
|
|
||
|
Local $SRC, $TYP, $FTR, $OUT, $USR, $PWD
|
||
|
|
||
|
If $CMDLINE[0] >= 1 Then
|
||
|
|
||
|
If $CMDLINE[1] = '/?' Then
|
||
|
__Usage__()
|
||
|
Exit
|
||
|
EndIf
|
||
|
|
||
|
For $i = 1 To $CMDLINE[0] Step 1
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/SRC:' Then $SRC = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/TYP:' Then $TYP = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/FTR:' Then $FTR = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/OUT:' Then $OUT = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/USR:' Then
|
||
|
$USR = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
Else
|
||
|
$USR = $gUSR
|
||
|
EndIf
|
||
|
|
||
|
If StringLeft($CMDLINE[$i], 5) = '/PWD:' Then
|
||
|
$PWD = StringTrimLeft($CMDLINE[$i], 5)
|
||
|
Else
|
||
|
$PWD = $gPWD
|
||
|
EndIf
|
||
|
Next
|
||
|
CheckFileExistence($SRC, $TYP, $FTR, $OUT, $USR, $PWD)
|
||
|
Return
|
||
|
Else
|
||
|
If Not IsArray($Configs) Then
|
||
|
ConsoleWrite(">>> Configuration Format Error !" &@CRLF)
|
||
|
Exit
|
||
|
EndIf
|
||
|
For $i = 1 To $Configs[0] Step 1
|
||
|
If $Configs[$i] <> 'Settings' And StringLeft($Configs[$i], 6) = 'Config' Then
|
||
|
$SRC = StringStripWS(IniRead($IniFile, $Configs[$i], "SourcePath", $gSRC), 2)
|
||
|
$TYP = Int(IniRead($IniFile, $Configs[$i], "ReturnType", $gTYP))
|
||
|
$FTR = IniRead($IniFile, $Configs[$i], "Filter", $gFTR)
|
||
|
$OUT = IniRead($IniFile, $Configs[$i], "Output", $gOUT)
|
||
|
|
||
|
If StringLeft($OUT, 2) = '.\' Then
|
||
|
$OUT = @ScriptDir&'\'&StringTrimLeft($OUT, 2)
|
||
|
EndIf
|
||
|
|
||
|
$USR = IniRead($IniFile, $Configs[$i], "User", $gUSR)
|
||
|
$PWD = IniRead($IniFile, $Configs[$i], "Password", $gPWD)
|
||
|
|
||
|
CheckFileExistence($SRC, $TYP, $FTR, $OUT, $USR, $PWD)
|
||
|
EndIf
|
||
|
Next
|
||
|
EndIf
|
||
|
EndFunc
|
||
|
|
||
|
|
||
|
|
||
|
Func CheckFileExistence($SourcePath=$gSRC, $iType=$gTYP, $Filter=$gFTR, $OutFile=$gOUT, $UserName=$gUSR, $PassWord=$gPWD)
|
||
|
;iType = 0 : Enum Files and Folders.
|
||
|
;iType = 1 : Enum Files.
|
||
|
;iType = 2 : Enum Folders.
|
||
|
;$SourcePath = '\\' &$SourcePath &'\Image\Zeus\'
|
||
|
Local $IP, $Check = 0, $Flag = 0
|
||
|
If StringLeft($SourcePath, 2) = '\\' Then
|
||
|
$IP = _StringBetween($SourcePath, '\\', '\')
|
||
|
If IsArray($IP) Then
|
||
|
$Check = Ping($IP[0], 1000)
|
||
|
If $Check = 0 Then
|
||
|
ConsoleWrite('Ping Host Error: ' & $IP[0] &@CRLF)
|
||
|
Return False
|
||
|
EndIf
|
||
|
EndIf
|
||
|
$Flag = DriveMapAdd('', $SourcePath, 0, $UserName, $PassWord)
|
||
|
EndIf
|
||
|
|
||
|
If FileExists($OutFile) Then FileDelete($OutFile)
|
||
|
|
||
|
Local $RESULT, $fOpen
|
||
|
Local $RESULT = _FileListToArrayRec($SourcePath, $Filter, $iType, 1, 1)
|
||
|
|
||
|
If IsArray($RESULT) Then
|
||
|
ConsoleWrite(@CRLF& '-----> Source: ' &$SourcePath &@CRLF &@CRLF)
|
||
|
;$RESULT = _ArraySearch($DirList, $Target, 0, 0, 0, 1)
|
||
|
$fOpen = FileOpen($OutFile, 9)
|
||
|
If $fOpen = -1 Then
|
||
|
FileClose($fOpen)
|
||
|
ConsoleWrite('Open File Failed: ' &$OutFile &@CRLF)
|
||
|
Return False
|
||
|
EndIf
|
||
|
For $i = 1 To $RESULT[0]
|
||
|
ConsoleWrite($RESULT[$i] &@CRLF)
|
||
|
FileWrite($fOpen, $RESULT[$i] &@CRLF)
|
||
|
Next
|
||
|
FileClose($fOpen)
|
||
|
Return True
|
||
|
EndIf
|
||
|
|
||
|
If $Flag = 1 Then DriveMapDel($SourcePath)
|
||
|
|
||
|
EndFunc
|
||
|
|
||
|
|
||
|
|
||
|
Func __Usage__()
|
||
|
Local $Tips = @CRLF & "FileList.exe V1.0" &@CRLF &@CRLF _
|
||
|
& "Parameters: " &@CRLF _
|
||
|
& StringFormat('%-20s%-s\r\n', '/SRC:[Source Path]', 'Initial path used to generate filelist.') _
|
||
|
& StringFormat('%-20s%-s\r\n', '/OUT:[Result File]', 'Initial path or file name used to write result.') _
|
||
|
& StringFormat('%-20s%-s\r\n', '/FTR:[Filter]', 'Filter, Include|Exclude|Exclude_Folders, Default="*||".') _
|
||
|
& StringFormat('%-20s%-s\r\n', '/TYP:[Return Type]', '0: Files & Folders, 1: Files Only, 2: Folders Only.') _
|
||
|
& StringFormat('%-20s%-s\r\n', '/USR:[Remote User]', 'Username for remote path (When SRC start with "\\").') _
|
||
|
& StringFormat('%-20s%-s\r\n', '/PWD:[Remote Pwd]', 'Password for remote path (When SRC start with "\\").') &@CRLF
|
||
|
ConsoleWrite($Tips)
|
||
|
Return
|
||
|
EndFunc
|
||
|
|