2012-04-04 97 views
5

我需要使用VB脚本“触摸”或更新文件夹上的DateLastModified属性。VBS如何更改文件夹上的DateLastModified属性

PowerShell不是一个选项,虽然我很感兴趣,如果它可能与PowerShell。

此外,我不想运行像GNU touch.exe这样的外部程序。该脚本将在多台计算机上运行,​​我无法保证将安装PowerShell或外部程序。

感谢任何线索或帮助,史蒂夫

P.S还问TechNet上。

回答

3

从这里:

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

如果要对一个文件夹这项工作,你必须设置的命名空间父文件夹,确保你添加一个尾随斜线的说法。然后你可以指定参数文件夹。无论如何,上次修改日期似乎没有在所有版本的Windows上更新文件夹。 – frumbert 2012-12-12 23:13:38

相关问题