Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Finding "Date Accessed" info for specific files

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,47455
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Finding "Date Accessed" info for specific files
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Finding "Date Accessed" info for specific files - 5/23/2007 2:33:01 AM   
  rgblois

 

Posts: 2
Score: 0
Joined: 5/23/2007
Status: offline
I am relatively new to VBScript and WSH, and I am trying to find out how to read the "Date Accessed" field for individual files, so I can determine when a piece of software was last run.  I've read the documentation for FileSystemObject, and can't find it even mentioned anywhere, and I can't find any info about it anywhere else.

Any help would be appreciated.

Thank you.

rgblois
 
 
Post #: 1
 
 RE: Finding "Date Accessed" info for specific... - 5/23/2007 2:42:24 AM   
  Rischip


Posts: 510
Score: 2
Joined: 3/26/2007
Status: offline
Try This

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
   ("Select * from CIM_Datafile Where name = 'c:\\pathandnameofyourfile'")
For Each objFile in colFiles
   Wscript.Echo "Access mask: " & objFile.AccessMask
   Wscript.Echo "Archive: " & objFile.Archive
   Wscript.Echo "Compressed: " & objFile.Compressed
   Wscript.Echo "Compression method: " & objFile.CompressionMethod
   Wscript.Echo "Creation date: " & objFile.CreationDate
   Wscript.Echo "Computer system name: " & objFile.CSName
   Wscript.Echo "Drive: " & objFile.Drive
   Wscript.Echo "8.3 file name: " & objFile.EightDotThreeFileName
   Wscript.Echo "Encrypted: " & objFile.Encrypted
   Wscript.Echo "Encryption method: " & objFile.EncryptionMethod
   Wscript.Echo "Extension: " & objFile.Extension
   Wscript.Echo "File name: " & objFile.FileName
   Wscript.Echo "File size: " & objFile.FileSize
   Wscript.Echo "File type: " & objFile.FileType
   Wscript.Echo "File system name: " & objFile.FSName
   Wscript.Echo "Hidden: " & objFile.Hidden
   Wscript.Echo "Last accessed: " & objFile.LastAccessed
   Wscript.Echo "Last modified: " & objFile.LastModified
   Wscript.Echo "Manufacturer: " & objFile.Manufacturer
   Wscript.Echo "Name: " & objFile.Name
   Wscript.Echo "Path: " & objFile.Path
   Wscript.Echo "Readable: " & objFile.Readable
   Wscript.Echo "System: " & objFile.System
   Wscript.Echo "Version: " & objFile.Version
   Wscript.Echo "Writeable: " & objFile.Writeable
Next

_____________________________

Rischip
Author of - The Grim Linker

(in reply to rgblois)
 
 
Post #: 2
 
 RE: Finding "Date Accessed" info for specific... - 5/23/2007 3:01:21 AM   
  rgblois

 

Posts: 2
Score: 0
Joined: 5/23/2007
Status: offline
Thanks, Rischip.  It appears that this is what I'm looking for.  Now I just have to figure out how to parse the date so I can get it in the format I want.

I appreciate the help.

rgblois

(in reply to Rischip)
 
 
Post #: 3
 
 RE: Finding "Date Accessed" info for specific... - 5/23/2007 4:15:51 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi rgblois,

you could use the FileSystemObject like this:

Dim oFS    : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim sFSpec : sFSpec  = ".\forum19.vbs"
Dim dtLA   : dtLA    = oFS.GetFile( sFSpec ).DateLastAccessed
WScript.Echo "dtLA", dtLA

All the interesting parts like GetFile() or .DateLastAccessed are
documented in the VBScript Docs.

How do you want have the dtLA formatted?

ehvbs

(in reply to rgblois)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Finding "Date Accessed" info for specific files Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts