Thursday, May 5, 2011

insert date and time stamp, vbs

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
From stackoverflow
  • You probably want the Now statement:

    NewTextFile.WriteLine(Now)
    

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

0 comments:

Post a Comment