Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 14th, 2006, 8:25 AM   #1
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
VBScript - Progress Bar

Howdy, I presently have some VBScripts that copy files between server and desktop and at the end of the process it pops up a Message Box to let you know it's done. I've had some of the tech complain that they have no way to tell that the script is running until they get the completed box. Is there any way to put in a progress bar to show the progress. Either that or a window that comes up and shows the file being moved. Below is what I am looking at in the script.

Dim X

set x=createObject("scripting.filesystemobject")

x.copyfolder "path1\*.*","path2\", True
x.copyfile "path3\*.*","path4\"
x.copyfile "path4\*.*","path5\"

set x= nothing

msgbox "Trainers Desktop Lotus Restore Finished!"

The pathx notation are just replacements for the folder locations.

Mind you, I didn't make the scripts. We've had them for a while. I've just taken up the responsibility for alot of new things. I've only been through one semester of VB and just learned OOP basics. I've made a few scripts but they were rather simple.

Any help is appreciated.

-Marshall
randum77 is offline   Reply With Quote
Old Jun 14th, 2006, 8:33 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
This question has come up before. Here's the nub of the problem. Typical web client/server interactions are more like a walkie-talkie than a telephone. A request is made by the client, the server responds, the connection is broken. The client then makes a further request at another time, if desired. The server may not (absent subversion of the intended method of operation) institute a transaction such as unilaterally sending a progress indicator to the client. You can understand why this is -- servers could bombard unwilling clients mercilessly. You CAN subvert this if your client is willing to stand for it. In your situation, the client is doubtless willing (at least for this one application). Consequently, set up a timer on the client and request a progress page at whatever interval you think is appropriate. A really frequent interval would be a Bad Thang as it represents a virtually useless load on the server and the infrastructure. Useless in the sense that it's merely patting the techs on the butt to stop their whining.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 14th, 2006, 8:51 AM   #3
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
Thank you for the reply DaWei. It's mainly just to get the Techs to stop wining. Although I am not highly fluent w/ VB yet, I'll take this and run with it a bit to see if i can't figure something out. I am hoping that next semester as school will teach a bit more then this last one.
randum77 is offline   Reply With Quote
Old Jul 12th, 2006, 4:39 PM   #4
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
DaWei: I think this is more a system admin application of VBScript than a web-page one (though it could be it's both).

If you're running VB through the Windows Scripting Host, it's not easy to pop up a progress bar. You can use MsgBox and InputBox to interact with the user (consider yourself lucky; JScript running through the WSH doesn't even have an InputBox to play with!) but progress bars are far trickier.

In the olden days, people used to create instances of IE as automation objects within their WSH hosted VB/JScripts and squirt HTML into them to build forms and pages and interact with the user, but IE's 'security enhancements' have pretty much broken this. If you know the end users have MS Office, you might be able to use Office apps to do this, but it's very fiddly (kind of like eating spaghetti with a pitchfork).

Another method that works is to write a tiny application that just displays a centered dialog with a message on it; you can pass this in from a command line argument so that your baby app is more generally useful. I wrote one of these called busy.exe (not very original I know); if you have it, you can call it from batch files, VBScript, JScript etc. and have it pop up then kill it when you're done. Mine wasn't a progress bar (that would be quite involved) - just a fairly plain 'busy dialog' that could be terminated in various ways from the outside but not in obvious ways the user could see. I don't have the code for that app lying around but it takes about 5 minutes in VB6 to throw something like this together. It gave me something I could throw onto the screen to say the machine was working on something. If you want it actually to grab the input focus and stop the user doing something else, you need to make Win32 API calls in VB6 since it doesn't have system modal forms built in.

To write really interactive GUI enabled scripts very quickly (and they're even portable between Win32, Unix and MacOS), it might be worth checking out Tcl/Tk (see http://www.tcl.tk/ ) - it'll involve a bit of a learning curve but I do think you'll find it's worth it. Alternatively, there's always VB6; if you can already write VBScript, you can learn VB6 in an afternoon and it gives you a lot more flexibility than VBScript while still having easy access to the various ActiveX objects (like Scripting.FileSystemObject) that you're used to using. It's not as good as Tcl/Tk but it'd probably be faster for you to learn, and now that it's obsolete you should be able to pick it up cheaply

Whew, anyway, best of luck.
__________________
"I'm not a genius. Why do I have to suffer?"
mackenga is offline   Reply With Quote
Old Jul 26th, 2006, 1:42 PM   #5
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
Mack, thank you again. I ended up going about the same route w/ the progress bar as you've suggested in your 4rd paragraph. I fired up VB.net and took advantage of the imports and picture box. I made an application that would pop up a window w/ an animated .Gif that duplicated the same look as a status bar. It works for now till I can figure out a more accurate way. I'm getting all excited for fall semester, i'm going to take Advanced VB. I get to learn how to interact with databases! Wooo!
__________________
_Marshall_

"America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt."
randum77 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC