Click to See Complete Forum and Search --> : date of last run
andy symmons
August 29th, 2001, 06:13 AM
Can anyone tell me how to call the date and time of the last time a vb5 exe has been run? What I have is an exe project that copies a file from one dir to another(this is how i am backing a project up) but what i want is to print on the form when it is opened the date and time that it was last run.
Thanks in advance for any help in this matter
CodeHacker
August 29th, 2001, 09:16 AM
Wouldn't it just be the date of the file in the new directory? Is there a chance that "backup" could be written over by another application?
CodeHacker
Rate me if it helped, Thanks
Cimperiali
August 29th, 2001, 09:28 AM
'what about writing and reading it in a small txt file (or in registry with
'savesetting,...)?
'ie:
option Explicit
private Sub Form_Load()
Dim lastD
If Dir("lstrun.txt") = "" then
Open "lstRun.txt" for Output as #1
print #1, date
Close #1
End If
Open "lstRun.txt" for input as #1
Line input #1, lastD
Close #1
me.Caption = lastD
End Sub
private Sub Form_Unload(Cancel as Integer)
Open "lstRun.txt" for Output as #1
print #1, date
Close #1
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
andy symmons
August 29th, 2001, 10:28 AM
i have tried to make it as simple as possible and all i want is to have the date and time that it was last run printed on the form so that i can see when it was last run when i open the program
Thanks in advance for any help in this matter
DSJ
August 29th, 2001, 10:45 AM
Try this...
private Sub Form_Load()
me.Caption = GetSetting(App.Title, "Settings", "LastRun", "")
End Sub
private Sub Form_Unload(Cancel as Integer)
SaveSetting App.Title, "Settings", "LastRun", Now()
End Sub
(You'll have to run it twice since the first time the time/date hasn't been saved yet.)
d.paulson
August 29th, 2001, 01:27 PM
The filesystemobject has a date last assessed property. Will that work? I know that it is not a date last run because this property will be updated if someone tried to open the exe with notepad etc., but it is as close as you're gonna get without using the procedures as already described in the previous posts.
David Paulson
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.