Solved

Change Modified Date On System Files?

Posted on 2001-07-12
9
201 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Technology Partners: 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
message box in access 4 55
Advice in Xamarin 21 118
VBA: copy range dynamically based on config sheet v2 3 59
add criteria to query in VB, Access 2003 2 47
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

739 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