[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to use Vbscript to time copying a file to memory

Posted on 2008-01-30
4
Medium Priority
?
896 Views
Last Modified: 2012-06-27
Hi Experts,

I would like to use Vbscript running from a command line that will time how long it takes to copy a file to memory.

The goal is to be able to measure the speed of a LAN connection.  
By copying a Server file to workstation memory rather than to hard disk, the results shouldn't be influenced by the destination hard disk speed.

Regards,
Leigh
0
Comment
Question by:LeighWardle
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Lester_Clayton
ID: 20785328
Here ya go. With this script, it will take all the files you pass to it as arguments (even if it's just one), and copy them to memory.
Option Explicit
On Error Resume Next
 
Dim objFSO, objArgs, strArg
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
 
For Each strArg in objArgs
  objFSO.CopyFile strArg, "NUL"
Next

Open in new window

0
 
LVL 1

Author Comment

by:LeighWardle
ID: 20785426
Hi Lester,

That code looks good.
Can you just modify it to output the elapsed time, as asked in the question.

Thanks,

Regards,
Leigh
0
 
LVL 9

Accepted Solution

by:
Lester_Clayton earned 2000 total points
ID: 20786021
Yup, no problemmo here you go.
Option Explicit
 
Dim objFSO, objArgs, strArg, Start, Finish, StartSecs, FinishSecs, ElapsedSecs, TotalSizes, File, Speed
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
 
Start = Now
StartSecs = Hour(Start)*360 + Minute(Start)*60 + Second(Start)
For Each strArg in objArgs
  Set File = objFSO.GetFile(strArg)
  TotalSizes = TotalSizes + File.Size
  objFSO.CopyFile strArg, "NUL"
Next
Finish = Now
FinishSecs = Hour(Finish)*360 + Minute(Finish)*60 + Second(Finish)
ElapsedSecs = FinishSecs - StartSecs
if ElapsedSecs > 0 Then
  Speed = TotalSizes / ElapsedSecs / 1024
Else
	Speed = "Undetermined"
End If
WScript.Echo "Start : " & Start & " Finish : " & Finish & " Duration in seconds : " & ElapsedSecs & " Total Bytes Copied : " & TotalSizes & " Speed " & Speed & " kB/sec"

Open in new window

0
 
LVL 1

Author Closing Comment

by:LeighWardle
ID: 31426633
Thanks, Lester.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question