Solved

Change Modified Date On System Files?

Posted on 2001-07-12
9
196 Views
Last Modified: 2011-08-18
Hi all,

 After installing SP5 on my computer , I found that some dummy(me) had set the clock to year 2010 instead of 2001.

 Of course this set all the installed file's dates to 2010. How do I change the modified date on system files to reflect the present date?

 Thanks for any help!

 Magoo (aka mr swooft typer)
0
Comment
Question by:magoo2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6278783
Reinstall everything with the date set to the current date is the only way, SORRY

-Dave
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6278919
You could try opening each one in code and then closing them. That might count as modified. Or you could open them, read a byte, write it back to the file, then close them.
0
 
LVL 3

Accepted Solution

by:
andysalih earned 200 total points
ID: 6278971
cut and paste this

Option Explicit
 
 Private Type FILETIME
     dwLowDate  As Long
     dwHighDate As Long
 End Type
 
 Private Type SYSTEMTIME
     wYear      As Integer
     wMonth     As Integer
     wDayOfWeek As Integer
     wDay       As Integer
     wHour      As Integer
     wMinute    As Integer
     wSecond    As Integer
     wMillisecs As Integer
 End Type
 
Private Const OPEN_EXISTING = 3
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const GENERIC_WRITE = &H40000000
 
Private Declare Function CreateFile Lib "kernel32" Alias _
   "CreateFileA" (ByVal lpFileName As String, _
   ByVal dwDesiredAccess As Long, _
   ByVal dwShareMode As Long, _
   ByVal lpSecurityAttributes As Long, _
   ByVal dwCreationDisposition As Long, _
   ByVal dwFlagsAndAttributes As Long, _
   ByVal hTemplateFile As Long) _
   As Long

Private Declare Function LocalFileTimeToFileTime Lib _
     "kernel32" (lpLocalFileTime As FILETIME, _
      lpFileTime As FILETIME) As Long

Private Declare Function SetFileTime Lib "kernel32" _
   (ByVal hFile As Long, ByVal MullP As Long, _
    ByVal NullP2 As Long, lpLastWriteTime _
    As FILETIME) As Long

Private Declare Function SystemTimeToFileTime Lib _
    "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime _
    As FILETIME) As Long
   
Private Declare Function CloseHandle Lib "kernel32" _
   (ByVal hObject As Long) As Long

Public Function SetFileDateTime(ByVal FileName As String, _
  ByVal TheDate As String) As Boolean
'************************************************
'PURPOSE:    Set File Date (and optionally time)
'            for a given file)
         
'PARAMETERS: TheDate -- Date to Set File's Modified Date/Time
'            FileName -- The File Name

'Returns:    True if successful, false otherwise
'************************************************
If Dir(FileName) = "" Then Exit Function
If Not IsDate(TheDate) Then Exit Function

Dim lFileHnd As Long
Dim lRet As Long

Dim typFileTime As FILETIME
Dim typLocalTime As FILETIME
Dim typSystemTime As SYSTEMTIME

With typSystemTime
    .wYear = Year(TheDate)
    .wMonth = Month(TheDate)
    .wDay = Day(TheDate)
    .wDayOfWeek = Weekday(TheDate) - 1
    .wHour = Hour(TheDate)
    .wMinute = Minute(TheDate)
    .wSecond = Second(TheDate)
End With

lRet = SystemTimeToFileTime(typSystemTime, typLocalTime)
lRet = LocalFileTimeToFileTime(typLocalTime, typFileTime)

lFileHnd = CreateFile(FileName, GENERIC_WRITE, _
    FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, _
    OPEN_EXISTING, 0, 0)
   
lRet = SetFileTime(lFileHnd, ByVal 0&, ByVal 0&, _
         typFileTime)

CloseHandle lFileHnd
SetFileDateTime = lRet > 0

End Function


does what you want it to do

hope this helps

andy
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:khampton
ID: 6279523
The easy fix might be to change your system date to the correct (current date), move all desired files to a temp folder then copy them back to where they should be.

If you search MSDN, you will see that there is a bug that causes the last modified date on the directory to change when you copy files...(sometimes).
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6279981
Andy has the answer.

Used this bit of code before

Vin.
0
 
LVL 1

Expert Comment

by:khampton
ID: 6281387
I agree that Andy's code will change the file date and it may be the only way to fix your problem.  But my suggestion is at least worth a try.  It may not work but if it does, it will be a much easier solution.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6281886
Hi!

Here's a file over the net for you:

Download...
http://www.vb-helper.com/Howto/setftime.zip

Description: Set a file's creation, last access, and last modified times (4K)

That's it!

glass cookie : )
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6283559
anybody alive on this one
0
 
LVL 1

Author Comment

by:magoo2
ID: 6296704
Hi,

 Sorry to take so long getting the points to you Andy. The code works like a charm. Thanks a lot!

 Thanks to all for the comments also!

 Magoo
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 68
MS Access 03, TransferText, decimal places 8 85
Export Data to Different .csv Files 26 121
checkbox to hide entire section 10 58
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question