HTA file - display status running vbscript

My script is very simply code. Display status in HTA form while running vbscript, but this script show status after script running, why?

<title>Deloitte User Profile Migration</title>
<link href="css\Wizard.css" type="text/css" rel="stylesheet">
<HTA:APPLICATION ID="oProfileMigration"
      APPLICATIONNAME="Profile Migration"
<script language="vbscript" type="text/vbscript">
Sub Window_onload
on error resume Next
      CenterWindow 640,480
End Sub      
Sub CenterWindow( widthX, heightY )
    self.ResizeTo widthX, heightY
    self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
End Sub

'Button Start
Sub ButtonNextClick
      If buttonnext.Disabled then
            exit sub
      End if
      Call StartSearch
End sub

'Button Cancel
Sub ButtonCancelClick
      If msgbox ("Are you sure you want to cancel?",4,"Cancel Backup?") = vbYes then
      End if
End Sub

Sub KeyHandler
              if window.event.KeyCode = 27 then
                             elseif window.event.KeyCode = 13 then
                                          window.event.returnValue = FALSE
             end if
End Sub

'Execute code
Sub StartSearch
      ButtonNext.disabled = true
                     'Show Status After running script
      StatusArea.InnerHTML="Searching Office Data Files in c:\ <br>"

Dim oFSO
Dim strUserName
Dim oShell
Dim oEnv

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
Set oEnv = oShell.Environment("SYSTEM")
strUserName = oShell.ExpandEnvironmentStrings("%username%")

SearchPST (oFSO.GetFolder("F:\"))
end sub
Sub SearchPST(objCurrentFolder)

   Dim strTemp
   Dim strOutput
   Dim objNewFolder
   Dim objFile
 On Error Resume Next
    For Each objFile In objCurrentFolder.Files
         strTemp = Right(objFile.Name, 4)
               If UCase(strTemp) = ".PST" Then
                  wscript.echo CStr(objFile.Path)
                  'oFSO.CopyFile CStr(objFile.Path), "D:\Dados\" & StrUsername & ".$$$" & "\OldPST\" & Date & " " & CStr(objFile.Name)
            End If
      'For Each objNewFolder In objCurrentFolder.subFolders
      '      SearchPST (objNewFolder)
      For Each objNewFolder In objCurrentFolder.subFolders
  If objNewFolder <> "F:\Documents and Settings\rgaspar\Local Settings\Application Data\Microsoft\Outlook" Then SearchPST (objNewFolder)
On Error Goto 0
      End Sub
<body Language="VBScript" onkeydown="KeyHandler">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" style="height: 100%;">
            <tr valign="top">
                <td colspan="2" >
                    <div id="MyContentArea" class="ContentArea" >
                        <H1>Deloitte User Migration</H1>
                        <span style="width: 95%;">
                            <table cellpadding="0" cellspacing="0" border="0">
                                    <td colspan="2" id="StatusArea"></td>

                                            <td colspan="2" id="CountArea"></td>

            <td class="CommandArea" id="RightWizardButtons" align="right">  
                <button accesskey=N type=submit id=buttonNext onclick=ButtonNextClick ><U>S</U>art</button>
                <button accesskey=C id=buttonCancel onclick=ButtonCancelClick><U>C</U>ancel</button>

Who is Participating?
ricgasparAuthor Commented:
Hello mplungian,

I accept you comment because your code is right.
So i found this script, see attachment. This script blink status while running vbscript, and stop blink and write status another line when script finish.

Michel PlungjanIT ExpertCommented:
I would code

'Button Start
Sub ButtonNextClick
      If buttonnext.Disabled then
            exit sub
      End if
      StatusArea.InnerHTML="Searching Office Data Files in c:\ <br>"
      Call StartSearch
End sub

and remove it from the search sub routine to give the browser time to execute the statement

Michel PlungjanIT ExpertCommented:
Did my code work as advertised?
If so, why the "B", if not why no comments?

ricgasparAuthor Commented:
Hello, please copy and paste my code and run.
Your code and my code show StatusArea.InnerHTML="Searching Office Data Files in c:\ <br>"
after and finished sub searchpst.
I like a before and running script sub searchpst show status.area.

Michel PlungjanIT ExpertCommented:
So why accept my comment

In JavaScript you need to take status messages out of functions that run loops. I expected the same in VB

I was obviously wrong, so a comment to that effect or deleting the question would have been better


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.