S-Skelly Posted July 7, 2015 Share Posted July 7, 2015 Hello, I am trying to write an AutoIt script that will continuously check a specific network directory for new files, if any new files that are found that have the .exe extension , then I want to launch said application.- I know the Major & Minor Revision numbers for these applications but not the "Developer" numbers (i.e. GF_V2.1.xxx.xxx)- The Network directory will never change- Other file types will exist in this network directory, I need to ignore them.- 200+ older exe's already exist in this network directory, I only want new files to be launchedThe difficulty I'm having is that I don't actually know the complete name of the file, so I cannot use the "FileExists" function to my knowledge.Any help would be very much appreciated Link to comment Share on other sites More sharing options...
wisem2540 Posted July 7, 2015 Share Posted July 7, 2015 Check out $aFileList = _FileListToArray ($Path,$Filter,1,True); you can use $FILTER to only return EXEs and even partial namesthen this... $ADATE = FileGetTime($aFileList[$I], 1, 0);1 = get created date $SDATE = $ADATE[0] & "/" & $ADATE[1] & "/" & $ADATE[2];split and format $Daysold = _DateDiff("D", $SDATE, _NowCalcDate());get date difference if you need it Link to comment Share on other sites More sharing options...
Danyfirex Posted July 7, 2015 Share Posted July 7, 2015 Loop from all the exe files (maybe filelisttoarray). check date creation then shellexecute.maybe something like this#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; List all the files and folders in the desktop directory using the default parameters. $networkDirectoy=@DesktopDir Local $aFileList = _FileListToArray($networkDirectoy, "*.exe") If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. _ArrayDisplay($aFileList, "$aFileList") for $i=1 to $aFileList[0] ConsoleWrite($networkDirectoy & "\" & $aFileList[$i] & @CRLF) ;check for date creation or anything you need Next EndFunc ;==>Example Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted July 7, 2015 Share Posted July 7, 2015 (edited) Another way get file list like this get all files name using._FileListToArray()and then save it as .INI and compare you new array with old saved INI file .edit:::you can use this function to convert array to ini or ini to array. Edited July 7, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Starstar Posted July 7, 2015 Share Posted July 7, 2015 (edited) expandcollapse popup#include <Array.au3> #include <File.au3> Global $defaultSeparator = Opt("GUIDataSeparatorChar", "|") Global $defaultSeparatorString = "<%Separator%>" Global $networkDirectory = @DesktopDir $sScriptName = @Compiled ? @ScriptName : StringRegExpReplace(@AutoItExe, ".+\\", "") While 1 ;Avoiding from double processing $aList = ProcessList($sScriptName) If $aList[0][0] = 1 Then ExitLoop For $i = 1 To $aList[0][0] If $aList[$i][1] <> @AutoItPID Then ProcessClose($aList[$i][1]) Next WEnd Local $aFileList = _FileListToArray($networkDirectory, "*exe",1) If @error = 1 Then MsgBox(0, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox(0, "", "No file(s) were found.") Exit EndIf _arrayToIni("Ntwrk.ini","EXE Files",$aFileList) ;Create a list of all files here desktop While 1 $aFileList = _FileListToArray($networkDirectory, "*exe",1) $oldlist = IniReadSection("Ntwrk.ini","EXE Files") If Not @error Then If ($oldlist[0][0]-1) > $aFileList[0] Then ;Incase delete reset EXE file list $aFileList = _FileListToArray($networkDirectory, "*exe",1) FileDelete(@desktopdir&"\Ntwrk.ini") _arrayToIni("Ntwrk.ini","EXE Files",$aFileList) EndIf If ($oldlist[0][0]-1) < $aFileList[0] Then $aFileList = _FileListToArray($networkDirectory, "*exe",1) $L = $aFileList[0] $find=_ArrayFindAll($oldlist,$aFileList[$L]) If @error = 6 Then $aFileList = _FileListToArray($networkDirectory, "*exe",1) $L = $aFileList[0] $ans = MsgBox(4,"Alert","New file is: "& $aFileList[$L] &" Do You Want Execute???") If $ans = 7 Then WinClose("Alert") ElseIf $ans = 6 Then $aFileList = _FileListToArray($networkDirectory, "*exe",1,True) $L = $aFileList[0] ShellExecute($aFileList[$L]) EndIf _arrayToIni("Ntwrk.ini","EXE Files",$aFileList) EndIf EndIf EndIf WEnd Func _arrayToIni($hFile, $sSection, $aName) ;;;BY Detefon Local $iLines = UBound($aName) Switch UBound($aName, 2) Case 0 Local $sTemp = "" For $ii = 0 To $iLines - 1 $aName[$ii] = StringReplace($aName[$ii], @LF, "At^LF") $sTemp &= $ii & "=" & $aName[$ii] & @LF Next IniWriteSection($hFile, $sSection, $sTemp, 0) Case Else Local $aTemp[1], $sString = "", $iColumns = UBound($aName, 2) For $ii = 0 To $iLines - 1 For $jj = 0 To $iColumns - 1 $aName[$ii][$jj] = StringReplace($aName[$ii][$jj], $defaultSeparator, $defaultSeparatorString) $sString &= $aName[$ii][$jj] & $defaultSeparator Next _ArrayAdd($aTemp, StringTrimRight($sString, 1)) $sString = "" Next _ArrayDelete($aTemp, 0) _arrayToIni($hFile, $sSection & "#" & $iColumns & "#" & $defaultSeparator & "#" & $defaultSeparatorString, $aTemp) EndSwitch EndFunc ;==>_arrayToIniTry this one Edited July 7, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
S-Skelly Posted July 16, 2015 Author Share Posted July 16, 2015 Thank you for all your help, I decided to start from scratch and re-write the system, however you guys helped a lot with the snippets of code / information, so for that I thank you all!Kind regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now