delete file after period of time

When supervisors are logged onto the system, a file exists in a directory:

If supervisor 248 is logged in, h:\kronos\data\supr248.001 exists.

The problem is users sometimes log on and forget to log off.  I can bump them off by deleting their supervisor file, ie. del supr248.001

The file is always the same format supr###.001  if it is supervisor 10, the file is supr10.001.

I would like to set up an executable that deletes the file if it exists for more than 1 hour.

What would the code look like?
dakarrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dakarrAuthor Commented:
The OS is WinNT if that makes any difference.
0
deightonprogCommented:
Dim t
Dim sFile
Dim n As Integer

'where n is your supervisor number

On Error GoTo bomb

n = 10

sFile = "supr" & Format(n, "000") & ".001"

t = CDate(FileDateTime(sFile))

If DateDiff("s", t, Now) > 3600 Then

    Kill sFile
   
End If

bomb:
   


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deightonprogCommented:
Private Sub logoff(n As Integer)

Dim t
Dim sFile

'where n is your supervisor number

On Error GoTo bomb

n = 10

sFile = "supr" & Format(n, "000") & ".001"

t = CDate(FileDateTime(sFile))

If DateDiff("s", t, Now) > 3600 Then

    Kill sFile
   
End If

bomb:
   

End Sub
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

deightonprogCommented:
In your case though, your path might need adding

Private Sub logoff(n As Integer)

Dim t
Dim sFile

'where n is your supervisor number

On Error GoTo bomb

n = 10

sFile = "h:\kronos\data\" & "supr" & Format(n, "000") & ".001"

t = CDate(FileDateTime(sFile))

If DateDiff("s", t, Now) > 60 Then

    Kill sFile
   
End If

bomb:
   

End Sub
0
dakarrAuthor Commented:
The format is set at "000" but may actually be "0", "00", or "000".  Will this be okay with that?
0
deightonprogCommented:
I was assuming 010 etc, so you need to use the following with format replaced with cstr



                    Private Sub logoff(n As Integer)

                    Dim t
                    Dim sFile

                    'where n is your supervisor number

                    On Error GoTo bomb

                    n = 10
'change required
 sFile = "h:\kronos\data\" & "supr" & cstr(n) & ".001"

                    t = CDate(FileDateTime(sFile))
'delete if 3600 seconds older
                    If DateDiff("s", t, Now) > 3600 Then

                        Kill sFile
                         
                    End If

                    bomb:
                         

                    End Sub
0
dakarrAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.