Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Set File Creation Date

Reply
 
Old 10-06-2008   #1 (permalink)
Peter


 
 

Set File Creation Date

I have a script that deletes a file 'MyFile.txt' on the local computer and
then copies a newer version of the same file from a network location to the
local computer at the same location as the one it just deleted.

That's okay, but then another process relies on the newly copied file on the
local computer to have a file creation date equal to when the file was copied.

The file creation date seems to be a very hit and miss affair in terms of
how the NTFS file system manages it, sometimes I get a new file creation
date, sometimes not.

After much investigation into how NTFS works I have concluded that file
creation date is not a particularly reliable way of keeping tabs on just how
old a file is - however, be that as it may, I am stuck with it.

So my question is this - using vbscript, can I set the file creation date at
the time of the copy or is this beyond vbscript?

Thanks for any help.

--
Regards - Peter


My System SpecsSystem Spec
Old 10-07-2008   #2 (permalink)
Todd Vargo


 
 

Re: Set File Creation Date

Peter wrote:
Quote:

> I have a script that deletes a file 'MyFile.txt' on the local computer and
> then copies a newer version of the same file from a network location to
the
Quote:

> local computer at the same location as the one it just deleted.
>
> That's okay, but then another process relies on the newly copied file on
the
Quote:

> local computer to have a file creation date equal to when the file was
copied.
Quote:

>
> The file creation date seems to be a very hit and miss affair in terms of
> how the NTFS file system manages it, sometimes I get a new file creation
> date, sometimes not.
>
> After much investigation into how NTFS works I have concluded that file
> creation date is not a particularly reliable way of keeping tabs on just
how
Quote:

> old a file is - however, be that as it may, I am stuck with it.
>
> So my question is this - using vbscript, can I set the file creation date
at
Quote:

> the time of the copy or is this beyond vbscript?
Yes, delete the file, sleep 15 seconds, then copy the file.
The key is the 15 second delay between delete and copy.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 10-07-2008   #3 (permalink)
esska


 
 

Re: Set File Creation Date

Instead of waiting 15 seconds it's better to do 3rd option from
WShell.Run - WaitOnRun
WshShell.Run(Command, [WindowStyle], [WaitOnRun])

You don't have to wait some part of time (by guessing how long it
should wait on it)

Regards,
esska
My System SpecsSystem Spec
Old 10-07-2008   #4 (permalink)
Todd Vargo


 
 

Re: Set File Creation Date

esska wrote:
Quote:

> Instead of waiting 15 seconds it's better to do 3rd option from
> WShell.Run - WaitOnRun
> WshShell.Run(Command, [WindowStyle], [WaitOnRun])
>
> You don't have to wait some part of time (by guessing how long it
> should wait on it)
Try it your way. The file creation date will not be reset. In the off chance
it works, please post the actual code that you used.

In the meantime, 15 seconds is not a guess. it's a default time set by
Windows. Read the following about File System Tunneling (which I recently
learned about in microsoft.public.scripting.wsh).

http://support.microsoft.com/?kbid=172190

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 10-07-2008   #5 (permalink)
Peter


 
 

Re: Set File Creation Date

"Todd Vargo" wrote:
Quote:

> esska wrote:
Quote:

> > Instead of waiting 15 seconds it's better to do 3rd option from
> > WShell.Run - WaitOnRun
> > WshShell.Run(Command, [WindowStyle], [WaitOnRun])
> >
> > You don't have to wait some part of time (by guessing how long it
> > should wait on it)
>
> Try it your way. The file creation date will not be reset. In the off chance
> it works, please post the actual code that you used.
>
> In the meantime, 15 seconds is not a guess. it's a default time set by
> Windows. Read the following about File System Tunneling (which I recently
> learned about in microsoft.public.scripting.wsh).
>
> http://support.microsoft.com/?kbid=172190
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)
>
Thanks for the help, yeah the 15 seconds rings a bell and seems to produce a
more reliable result, pity about the introduced delay but can't be avoided.
I had read all about File System Tunnelling, I must admit, I never realised
that the file system did so much until I started investigating this issue.

Thanks again for the help.

Peter
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How do I get a folder's creation date? PowerShell
Command line tool to change file creation date? Vista General
display document creation date Vista file management
How can I preserve creation date in a Copy? Vista file management
sort by file creation date Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46