Hi,
I am trying to compress a file whose size is inconsistent and may vary everytime.
So, each time I have to increase the sleep time for bigger size files after the script fails to zip it.
below is the code:
------------------------
Set winsh = CreateObject("WScript.Shell")
Set winenv = winsh.Environment("Process")
windir = winenv("WINDIR")
StrFileName = windir &"\temp\Abc\Abc.log"
StrPath = windir &"\temp\ABC.zip"
Const adTypeBinary = 1
Const adTypeText = 2
Const adSaveCreateNotExist = 1
Const adSaveCreateOverwrite = 2
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeText
objStream.WriteText ChrB(&h50) & ChrB(&h4B) & ChrB(&h5) & ChrB(&h6)
For i = 1 To 18
objStream.WriteText ChrB(&h0)
Next
objStream.SaveToFile StrPath, adSaveCreateNotExist
objStream.Close
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile StrPath
objStream.Position = 2
arrBytes = objStream.Read
objStream.Position = 0
objStream.SetEOS
objStream.Write arrBytes
objStream.SaveToFile StrPath, adSaveCreateOverwrite
objStream.Close
Set objStream = Nothing
set winShell = createObject("shell.application")
set objFile = winShell.namespace(StrPath)
objFile.CopyHere StrFileName,4
wScript.Sleep(1000) ->{{this is the grey area where i need help / any alternative}}
-----------------------------------------------------------------------
Is there any way to get rid of wScript.Sleep() line ?
Any alternatives ?
Please help me!
thanks in advance.