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

progressbar in VBS 1

Status
Not open for further replies.

Targol

Technical User
Sep 13, 2002
908
FR
In our new architecture, it has been told that all the old .BAT files used to connect network drives, set environment variables, etc... have to be change in .VBS scripts. I have a question about that :

Does anyone knows a solution to display a window or dialog that could inform the user the percentage of job done.
I'm look for a solution of that kind :
Code:
Set gauge=CreateObject("
object that i need
Code:
")
gauge.setLabel("beginning job")
...
gauge.setLabel("connecting network drives")
..
for i=1 to 100
  gauge.setLevel(i)
next
...
gauge.close()

If someone know the object that i need this sould be great. But all other solutions are welcome (ie : a dialog that once can open, change message and then close). For the moment, the only solution I found is the
Code:
WshShell.Popup Message, TimeBeforeClose , Title , type
method. But the problem with it is that I must call it many times to achieve what I want leading to many flashing dialogs that apears and diseapear.

Any help would be greatly appreeciated. Water is not bad as soon as it stays out human body ;-)
 
There are a number of possible solutions to this problem. Unfortunately I'm unaware of any really trivial ones.

The basic problem you have here is that you need some sort of GUI "canvas" container to hold whatever progressbar control you wish to use - I don't know of any that are standalone and do what you need. Well... there is this approach:
That might be a lot for a poor BAT-filer to swallow all at once though ;-)

It seems to me that most solutions boil down to about two possibilities: invoke IE and paint your GUI there or build a custom ActiveX server that does what you want.

A good example (or two!) of the first approach are found at on a site that has a lot of advanced scripting tips and goodies. Problem is, you need to be a little scriptlet-literate to understand the approach used here. Still, it might be worth fumbling with to see if you can get it working for you.

The second aproach is fairly obvious if you already have the know-how.

My preferred approach turns the 1st option inside-out. Instead of having a script invoke IE, have IE host your script!

That is, write your scripts as .HTAs instead of as .VBS or .WSF files. If you go to you will find a site that hasn't been updated in awhile... but on that page, about halfway down, you will find some information on creating HTAs, along with links to Microsoft info on the topic and a good example.

As always, you're going to learn a little bit to use this. Some DHTML experience will go a long way in writing HTAs. A quick search for "DHTML progressbar" using Google or somebody should get you a number of ways to build the bar itself.

The biggest problem I have found with HTAs is the lack of the Sleep method - most everything else you have in a WSH script can be had one way or another in an HTA. Mr. J. Warrington has a kludge or two for even that on his site though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top