I am using the following VBScript to retrieve date created, date last accessed and date last modified. This info is then put into an Excel spread sheet. I need to have the date format changed from WMI to dd/mo/year. I am somewhat new at scripting so not sure if this is the most efficient way of doing it. I am also wanting to figure out the "Days since last backup" which would be the current date minus the "date last modified". Any help would be greatly appreciated. Thanks.
Const ADS_SCOPE_SUBTREE = 2
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
StrComputer = "**" (left off server name)
Set objWMIService = GetObject ("sinmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
strFolderName = "e:\pst"
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
strFileName = "c:\temp\test.xlsx"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 2).Value = "Date Created"
objExcel.Cells(1, 3).Value = "Date last accessed"
objExcel.Cells(1, 4).Value = "Date last modified"
objExcel.Cells(1, 5).Value = "Needs Backup?"
objExcel.Cells(1, 6).Value = "Days since last backup"
objExcel.Columns(1).ColumnWidth = 25
objExcel.Columns(2).ColumnWidth = 25
objExcel.Columns(3).ColumnWidth = 25
objExcel.Columns(4).ColumnWidth = 25
objExcel.Columns(5).ColumnWidth = 25
objExcel.Columns(6).ColumnWidth = 25
objExcel.Range("A1:F1").Select
objExcel.Selection.Font.ColorIndex =1
x = 2
For Each objFolder In colSubfolders
objExcel.Cells(x, 1).Value = objFolder.name
objExcel.Cells(x, 2).Value = objFolder.creationdate
objExcel.Cells(x, 3).Value = objFolder.lastaccessed
objExcel.Cells(x, 4).Value = objFolder.lastmodified
'objExcel.Cells(x, 5).Value = Needs Backup?
'objExcel.Cells(x, 6).Value = Days since last backup.
x = x + 1
Next
objWorkbook.SaveAs(strFileName)
objExcel.Quit