VBS how can I change the DateLastModified property in a folder

I need to “touch” or update the DateLastModified property in a folder using VB Script.

PowerShell is not an option, although I am wondering if this is possible with PowerShell.

In addition, I have no desire to run an external program such as GNU touch.exe. The script will run on several computers, and I can not guarantee that PowerShell or external programs will be installed.

Thanks for any tips or help, Steve.

ps also asked about the technique.

+5
source share
1 answer

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
+3
source

All Articles