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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert a 1 second delay ?

Status
Not open for further replies.
Are you trying to put a delay in a HTA/HTML file?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Yes.

At the begiiniing of my HTML file I run a Vbscript that unzips a file,which is later on accessed from the HTML <body> and used as a HTML background.

What I need is to delay the HTML biuilding till the VBscript unzip operation is over.
How do I achieve it ?
Thanks

Long live king Moshiach !
 
Since you're calling an external .vbs file...if you're using WScript.Shell and the Run method, just set the waitonreturn.

i.e. objShell.Run "cscript somescript.vbs", 0, True

If inside the script you call you're calling the app to unzip then make sure to do the same thing.

objShell.Run "unzipapp.exe file.zip", 0, True

Alternately, you might call another .vbs file to do the sleeping for you using the first method I mentioned.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks,

To clarify:
The VBscript is INTERNAL inside my HTML. It apperas at the beginning of the HTML file,before the body.

So I'm not calling anything external,just need to delay the HTML building somehow till end of zip.
Thanks

Long live king Moshiach !
 
you can take the wscript.sleep out of your hta/html and put it in a .vbs script and run it from hta/html. it should work.
 
Yes,I understand.

However my implementation requires the delay to be internal in the HTML - I can not want to call external files.
Thanks

Long live king Moshiach !
 
try this one:
an HTML method called setInterval that enables you to “schedule” a block of code to run periodically.
Code:
iTimerID = window.setInterval("GetFreeDiskSpace", 120000)
GetFreeDiskSpace is a sub in vbscript in your hta.
120000 is 120 seconds (2 minutes).
 
Moshiach, what is your actual code that unzips the file ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The is also a window.setTimeout:
With an HTA though, I just find it so much easier to have a sleep.vbs that accepts as an argument the sleep length and helps me control the pauses as needed.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
if you're waiting for zip to produce a file, if it takes longer than the allowed time, then you may run into a problem. you can alternatively, do a loop that cheks for the "exist"ence of that file that you're waiting for. if it finds it, then you exit the loop and continue your work.
do until file_found
check the existence of file using fso methods
if file exists, file_found = true
loop
rest of your code.




 
PHV,

My actual unzip code that appears at the beginning of my HTML,before the "body" tag is :

<script language=VBScript>
set objShell=CreateObject("Wscript.Shell")
File3 = "C:\Program Files\WinZip\winzip32.exe"
strTemp = document.url
If Left(strTemp, 7) = "file://" Then
strTemp = Right(strTemp, Len(strTemp) - 7)
strCurrentFolder = Left(strTemp, InStrRev(strTemp, "\"))
strCurrentFolder = replace(strCurrentFolder, "%20", " ")
FullPath = (strCurrentFolder & "\POSSUP_KM_301_20070503_pod.zip")
FullPath1 = chr(34) & FullPath & chr(34)
End If

strCommand = "C:\Program Files\Pod Check tool\unzip.exe"
strCommand = chr(34) & strCommand & chr(34) & " -q -o " & chr(34) & FullPath & chr(34) & " -d d:\TEMP\POD "

if objFSO.FileExists (FullPath) then
if objFSO.FileExists (File3) then
objShell.Run("""%ProgramFiles%\WinZip\winzip32.exe"" -e -o " & FullPath1 & " D:\Temp\POD")
else
objShell.Run strCommand
end if
end if
objShell.Run("dir c:\")
</script>
===================================
I try first using "unzip" command,nad if not found - I run the "winzip".
I HAVE to use only ONE HTML (no HTA),that's how the job is implemented.
My customers runs a Perl script that creats just 1 HTML file on his desktop with ALL the system info inside it,plus cretaes an extra zip file with large logs inside it.
Thanks


Long live king Moshiach !
 
This is not delayed in the sense asked. This is synchroneity: sytem doing one time after another which is actually needed.
[tt]
if objFSO.FileExists (FullPath) then
if objFSO.FileExists (File3) then
objShell.Run[highlight] [/highlight]"""%ProgramFiles%\WinZip\winzip32.exe"" -e -o " & FullPath1 & " D:\Temp\POD"[highlight],[/highlight][red]0,1[/red]
else
objShell.Run strCommand[red],0,1[/red]
end if
end if
objShell.Run "[red]%comspec% /k [/red]dir c:\"
[/tt]
That script section should be placed at the top before the body.
 
Thanks,

ended up using delay as following,using just the "user" dos command as a delay:

do until file_found
if objFSO.FileExists (File4) then
file_found = true
end if
objShell.Run("user")
loop
</script>

Long live king Moshiach !
 
You know, people do really all kind of things.
 
Finally,used the following code that worked best for my needs:
===================================================

Sub ccSleep(seconds)
cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
objShell.Run cmd,0,1
End Sub

do until file_found
if objFSO.FileExists (File4) then
file_found = true
end if
ccSleep 1
loop

Thanks to all !

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top