Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display File Size then Quit

Status
Not open for further replies.

lpb71

Technical User
Joined
Mar 10, 2004
Messages
57
Location
GB
My script below is part of a script that exports files into one compressed file. I want my script below to check the file size and when it has not increased for 3 consecutive checks to report that the build is complete. I have managed to get it to report the file size, but I need it to keep checking the file size every 10 seconds and report complete if it has not changed in the last 3 checks.

Any Ideas how I can do this.


Set objExplorer = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible=1

do While (objExplorer.Busy)
Loop

Set objDocument = objExplorer.Document
objDocument.Open
objDocument.WriteLn "<html><head><title>LREP Data Replication</title></head>"
objDocument.WriteLn "<body bgcolor='white'>"
objDocument.WriteLn "Replicating Data to USB Device. Please Wait....<p>"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("d:\scripts\random.fil")
'wscript.echo("File Size so far = " & (objFile.Size) & "bytes")

objDocument.WriteLn("File Size so far =" & (objFile.Size) & " bytes")
 
Code:
Const TEN_SECONDS = 10000

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("d:\scripts\random.fil")

StartSize = objFile.Size

WScript.Sleep TEN_SECONDS
For i = 1 To 100
	CheckSize StartSize,0
Next


Function CheckSize(ValueToMatch, Counter)
	If Counter = 3 Then
		   WScript.Quit
	End If
	WScript.Sleep TEN_SECONDS
	Set objFile = objFSO.GetFile("c:\logs\devdatabase.mdb")
	If objFile.Size = ValueToMatch Then 
		NewSize = objFile.Size
		Counter = Counter + 1
		CheckSize NewSize, Counter
	Else
	   NewSize = objFile.Size
	   Counter = 0
	End If
End Function

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top