Jump to content
Sign in to follow this  
Tstudent

Check date before launch a file

Recommended Posts

Tstudent

Please, can you show me the most efficent way to do this?

i want to launch a file, but only if the time of another file is > then 09:00 pm

In another words: if the time (last saved) of "fileA.xls" is > then 09:00pm then open "fileB.bat" otherwise wait 1 minute and restart the control until the time condition is verified.

Is possible to do this with autoit?

Thank you

Share this post


Link to post
Share on other sites
DesireDenied

dont know if this is what you are looking for, have not tested but should do the trick.

$sFileToCheck = "FileA.xls"
$sFileToRun   = "FileB.bat"
 
While 1
    $aFileTime = FileGetTime($sFileToCheck)
    If IsArray($aFileTime) Then
        If $aFileTime[3] >= 9 Then
            Run($sFileToRun)
            ExitLoop
        Else
            Sleep(1000)
        EndIf
    EndIf
WEnd
Edited by DesireDenied

Share this post


Link to post
Share on other sites
Tstudent

dont know if this is what you are looking for, have not tested but should do the trick.

$sFileToCheck = "FileA.xls"
$sFileToRun   = "FileB.bat"
 
While 1
    $aFileTime = FileGetTime($sFileToCheck)
    If IsArray($aFileTime) Then
        If $aFileTime[3] >= 9 Then
            Run($sFileToRun)
            ExitLoop
        Else
            Sleep(1000)
        EndIf
    EndIf
WEnd

Thank you, works very well.

I have modified this code because i want add another check: i want that day, month and year of "FileA.xls" are equal to CURRENT day, month and year.

#include <Date.au3>
$sFileToCheck = "c:\AAA.xlsx"
$sFileToRun   = "c:\BBB.bat"
$tCur = _Date_Time_GetLocalTime()
$aCur = _Date_Time_FileTimeToArray($tCur)
 
While 1
    $aFileTime = FileGetTime($sFileToCheck)
    If IsArray($aFileTime) Then
       If $aFileTime[0] = $aCur[0] and $aFileTime[1] = $aCur[1] and $aFileTime[2] = $aCur[2] And $aFileTime[3] = 21 and $aFileTime[4] >= 41 Then
           Run($sFileToRun,"c:\")
           ExitLoop
       Else
           Sleep(10000)
       EndIf
    EndIf
WEnd

But day, month, year check doesn't work. Any ideas?

Thank you

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×