HTA file - display status running vbscript

Posted on 2008-11-19
Medium Priority
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
  • 3
  • 2
LVL 75

Expert Comment

by:Michel Plungjan
ID: 23003742
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
ID: 23093038
Did my code work as advertised?
If so, why the "B", if not why no comments?


Author Comment

ID: 23110164
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
ID: 23111205
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

ricgaspar earned 0 total points
ID: 23113533
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.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 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