Insert date and time stamp, vbs

vbscript

I'd like to insert the time and date of when the script was executed. So far I just have the username of the person who executed the script….

Set FSO = wscript.CreateObject("Scripting.FileSystemObject")
Set NewTextFile = FSO.OpenTextFile("UserInfo.flag",2,true)
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "User Name = " & WshNetwork.UserName
NewTextFile.WriteLine("Site replication was last executed by user:")
NewTextFile.WriteLine(WshNetwork.userName)
NewTextFile.Close
Set NewTextFile = Nothing
Set FSO = Nothing

Best Answer

You probably want the Now statement:

NewTextFile.WriteLine(Now)

Or, if you don't want time, use Date

Related Topic