I’m not sure how useful this script will be, but, a while ago somebody came to me and said “we need to test how much time it’s needed to copy a big file from a share over the network for the users, and please create logs so we can collect them and analyze them”. I am sure that there are many other ways you can test your intranet speed and collect logs after that, and decide if you can deploy your app for the whole infrastructure, or in waves of X machines so you don’t overload your network…but i am attaching the script anyway.
'------------------Variable initialization---------------------------------------------------- ' set filesys=CreateObject("Scripting.FileSystemObject") strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1)) Set WshShell = CreateObject("WScript.Shell") strUserName = WshShell.ExpandEnvironmentStrings( "%USERNAME%" ) '------------------Select file, copy location and log location-------------------------------- ' CopyFile = "C:\YourFile.txt" Destination = "D:\" outFile=strCurrentDir & "\" & strUserName & "-Copy-LOG.log" '------------------Operations----------------------------------------------------------------- Set objFile = filesys.CreateTextFile(outFile,True) objFile.Write "Copy file started at: " & Now() & vbCrLf time1 = Now() filesys.CopyFile CopyFile, Destination time2 = Now() seconds = DateDiff("s", time1, time2) intTotalSecs = seconds intHours = intTotalSecs \ 3600 intMinutes = (intTotalSecs Mod 3600) \ 60 intSeconds = intTotalSecs Mod 60 objFile.Write "File copied in: " & intHours & " hours " & intMinutes & " minutes and " & intSeconds & " seconds" & vbCrLf objFile.Close
It’s a quite straightforward script. After the variable initialization we define what file we want to copy, where we want to copy the file and where the log will be created.
Set objFile = filesys.CreateTextFile(outFile,True) objFile.Write "Copy file started at: " & Now() & vbCrLf time1 = Now()
We create the log file, note the starting copy time and initialize our first time.
filesys.CopyFile CopyFile, Destination time2 = Now()
We copy the file and mark the second time.
seconds = DateDiff("s", time1, time2) intTotalSecs = seconds intHours = intTotalSecs \ 3600 intMinutes = (intTotalSecs Mod 3600) \ 60 intSeconds = intTotalSecs Mod 60 objFile.Write "File copied in: " & intHours & " hours " & intMinutes & " minutes and " & intSeconds & " seconds" & vbCrLf objFile.Close
We make de difference between the first marked time and second and write into the log.
The log file should look something like this:
Copy file started at: 25/03/19 - Mon 9:53:08 PM File copied in: 1 hours 12 minutes and 31 seconds
As said, easy right?