For performance reasons, Windows was lying to me.

The creation date for a file I was creating, was 8 days out.  This was what I was trying to do:

IF logfile older than 7 days THEN
   1. delete the current log file
   2. create a new log file (with the same name)

When VBscript was creating the new log file, it was getting the creation date of the old file.  "So what?", you might be thinking.

As the log file was keeping the old file creation date, it was always executing the "IF logfile older than 7 days THEN" statement.

A bit of a Google search later, yielded this Microsoft article:

"When a name is removed from a directory (rename or delete), its short/long name pair and creation time are saved in a cache, keyed by the name that was removed. When a name is added to a directory (rename or create), the cache is searched to see if there is information to restore."
http://support.microsoft.com/?kbid=172190

Ah, so the operating system is caching the old file name and date in a "tunnelling cache" somewhere.  Now there are a couple of fixes available to me, such as disabling the "tunnelling cache".  But the fix I went for was, was to

IF logfile older than 7 days THEN
   1.  delete the current log file
   1a. wait 16 seconds.
   2.  create a new log file (with the same name)

Waiting 16 seconds works, as this is longer than the default tunnelling cache hold time (15 seconds).

The VBscript I was having problems with?  The SMS Client Health Startup Script.

Other blog posts on this subject:
Windows Date Created Timestamp strangeness
File tunnelling: weird creation timestamps

Comments are closed.