Recursing through folders without changing Last Accessed Date

Recursing through folders without changing Last Accessed Date

Post by sd_ha » Mon, 10 Apr 2006 23:15:40


HI all,
I am writing a script which should enumerate the Folder
permissions of a share. I was successful in doing this until i get a
new requirement which says that the Last Accessed dates should not be
changed.

I am using for each subfol in fol.subfolders to get
the subfolder properties (i.e, Path,size) but what i believe is, it is
the culprit which is changing the date. I tried using
Directory.GetDirectory to get the subdirectories but that attempt also
went into vain as it is also doing the same thing.

I tried using GetLastAccessTime and SetLastAccessTime for setting the
earlier time but to give the path as input i need to get it by using
fol.subfolder property only.

Please suggest me in this regard . I need some alternate solution for
this
 
 
 

Recursing through folders without changing Last Accessed Date

Post by Slim » Mon, 10 Apr 2006 23:30:17

last accessed date is there for a reason.
I doubt it can be tampered with, if it could it would help hackers cover
their tracks

 
 
 

Recursing through folders without changing Last Accessed Date

Post by R2VyYWxkby » Tue, 11 Apr 2006 00:05:02

sd_haf,

Sorry I cant help you but I wonder if you could let me know how youre
enumerating the folder permissions. I am a beginner scripter and need to do
something similar but xcalcs is just much too complicated for me at this
point...

Thanks in advance!
 
 
 

Recursing through folders without changing Last Accessed Date

Post by "Crash"Dum » Tue, 11 Apr 2006 04:23:40

> I am writing a script which should enumerate the Folder

How can you read the Date Last Accessed without accessing the file?
--
Crash

"You miss 100 percent of the shots you never take."
~ Wayne Gretzky ~
 
 
 

Recursing through folders without changing Last Accessed Date

Post by sd_ha » Tue, 11 Apr 2006 12:50:33

I am not trying to get the last accessed dates of a folder at this
point of time . but my problem is with getting the subfolder's
properties .When iam trying to do that , then it is changing time which
should not happen in requirement.
 
 
 

Recursing through folders without changing Last Accessed Date

Post by sd_ha » Tue, 11 Apr 2006 12:54:27

Iam using ADsSecurity.dll to do that .You need to register this dll on
the machine which you are running this script


secDesc = Nothing
DACL = Nothing
Try
secDesc = Sec.GetSecurityDescriptor("FILE://" & strpath)
DACL = secDesc.DiscretionaryAcl

For Each ACE In DACL
substr1 = ACE.Trustee
substr2 = ACE.accessMask

I got the access mask and from it i can derive the permission type .
 
 
 

Recursing through folders without changing Last Accessed Date

Post by Al Dunbar » Tue, 11 Apr 2006 14:32:29


Maybe not in your requirement. But the file system would seem to update the
"last accessed date" when the file or folder is "accessed", even if it is
only the properties that you are accessing and not the contents.

/Al
 
 
 

Recursing through folders without changing Last Accessed Date

Post by R2VyYWxkby » Tue, 11 Apr 2006 20:37:02

"Can you store the "current" last accessed dates to variables and then,
after accessing the necessary stuff, set them back to the originals? (sorry
if this is a stupid suggestion... just a a beginner...)

rgds!
 
 
 

Recursing through folders without changing Last Accessed Date

Post by Al Dunbar » Wed, 12 Apr 2006 12:21:53

I don't know how to do that, and suspect that it is not possible if using
the NTFS file system itself. What would be the point of the file system
tracking last access if that the date is not going to represent when the
file was actually last accessed.

But even supposing one could save the date, the action of modifying the
"last access date" would likely be enough to register as an access,
resulting in the field being updated once again.

What I am wondering is: "what is the business case for allowing admins (or
anybody, for that matter) to access files without detection"?


/Al



(sorry
 
 
 

Recursing through folders without changing Last Accessed Date

Post by sd_ha » Wed, 12 Apr 2006 12:47:55


Deleting the files which were accessed within 2 years. It would save
lot of space after migration to new system.
 
 
 

Recursing through folders without changing Last Accessed Date

Post by Al Dunbar » Wed, 12 Apr 2006 13:02:26


using
(or

<snip>


OK, that makes sense. given that "dir /t a" seems to work, and this is a
one-time thing, I'd tend to do it that way.

/Al
 
 
 

Recursing through folders without changing Last Accessed Date

Post by harrykrish » Sun, 16 Apr 2006 01:01:11

Don't know if this fits, but have you looked at the registry setting
NtfsDisableLastAccessUpdate?

http://www.yqcomputer.com/

Harry









Hay

XXXX@XXXXX.COM
 
 
 

Recursing through folders without changing Last Accessed Date

Post by Michael Be » Sun, 16 Apr 2006 20:25:56

n Fri, 14 Apr 2006 16:01:11 GMT, harrykrishna.nospam@... wrote in
microsoft.public.scripting.vbscript:


You are not suggesting that the OP change that setting, reboot, run his
enumeration of directory permissions, change the setting back again and
reboot once more?

I think that LastAccessDate is rather useless and I have always turned
it off, but it's not something that can be done on the fly.


Just because a file hasn't been accessed in a period doesn't necessarily
mean it can be deleted. It may well still have documentary/evidentiary
value. Conversely, because the LastAccessdate will be touched by all
sorts of innocuous actions, it does rarely reflect actual usage.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"