HTA file - display status running vbscript

Posted on 2008-11-19
Last Modified: 2012-05-05
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>

Question by:ricgaspar
    LVL 75

    Expert Comment

    by:Michel Plungjan
    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

    LVL 75

    Expert Comment

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


    Author Comment

    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.

    LVL 75

    Expert Comment

    by:Michel Plungjan
    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



    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
    This article will show, step by step, how to integrate R code into a R Sweave document
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now