Question : Adding timestamp to outfile File

Hello,

I have a vbscript that gets the file version of serval diffrerent local files, creates a output file, then
puts file version in a message string and writes to an ouput file. How do i add a timestamp to the output file?

This is what i have:

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Create the Output File
Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

' Get the Version of a File and put it in a Message string
For i = 0 To UBound( arrFiles )
                if arrFiles(i) <> "" then
                                ProcessFile arrFiles(i)
                End If
Next

' Close the Output File
objOutputFile.Close

Function ProcessFile( strFile )
                Dim strMsg, strVersion, timestamp
                ' Make sure the file exists
                If objFSO.FileExists( strFile ) = False Then
                                strMsg = strFile & " - File not found. "
                Else
                ' Get the Version of the File and put it in a Message string
                                strVersion = objFSO.GetFileVersion(strFile)
                        strtimestamp = time()
                                strMsg = strFile & " " & strVersion & strtimestamp
                End If

                ' Write the Message string to the Screen
                Wscript.Echo strMsg

                ' Write the Message string to the Output File (with a CR LF)
                objOutputFile.Write strMsg &vbCRLF
End Function

Answer : Adding timestamp to outfile File

try this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Create the Output File
Set objOutputFile = objFSO.CreateTextFile( strOutputFile, True, True )

' Get the Version of a File and put it in a Message string
For i = 0 To UBound( arrFiles )
                if arrFiles(i) <> "" then
                                ProcessFile arrFiles(i)
                End If
Next

' Close the Output File
objOutputFile.Close

Function ProcessFile( strFile )
                Dim strMsg, strVersion, timestamp
                ' Make sure the file exists
                If objFSO.FileExists( strFile ) = False Then
                                strMsg = strFile & " - File not found. "
                Else
                ' Get the Version of the File and put it in a Message string
                                strVersion = objFSO.GetFileVersion(strFile)
                        strtimestamp = time()
                                strMsg = strFile & " " & strVersion & strtimestamp
                End If

                ' Write the Message string to the Screen
                Wscript.Echo strMsg

                ' Write the Message string to the Output File (with a CR LF)
                objOutputFile.Write Now & ": " & strMsg &vbCRLF
End Function 
Random Solutions  
 
programming4us programming4us