VBS how can I change the DateLastModified property on a Folder

Go To StackoverFlow.com

5

I need to 'touch' or update the DateLastModified property on a folder using VB Script.

PowerShell isn't an option, although I am interested if it is possible with PowerShell.

Also, I'm have no wish to run an external program like GNU touch.exe. The script will run on multiple computers and I can't guarantee that PowerShell or external programs will be installed.

Thanks for any leads or help, Steve

p.s also asked on technet.

2012-04-04 16:41
by Steve F


3

From here:

http://www.tek-tips.com/viewthread.cfm?qid=1372273

ModFileDT "c:\rootdir", "folder", "1/01/2007 4:18:02 PM"

Function ModFileDT(strDir, strFileName, DateTime)

    Dim objShell, objFolder

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.NameSpace(strDir)
    objFolder.Items.Item(strFileName).ModifyDate = DateTime
End Function
2012-04-04 17:41
by Nathan Rice
To make this work on a FOLDER, you have to set the namespace to the PARENT folder, making sure you add a trailing slash to the argument. Then you can specify the folder into the argument. At any rate, the Date Last Modified doesn't seem to update on all versions of Windows, for folders - frumbert 2012-12-12 23:13
Ads