Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Progress Bar without using IE

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,23940
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Progress Bar without using IE
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Progress Bar without using IE - 7/22/2005 7:21:55 AM   
  jsou

 

Posts: 24
Score: 0
Joined: 7/22/2005
Status: offline
Hi everyone,
I'm pretty new to scripting and i'm trying to create a Progress Bar of my work ro my just like a message that will show up until my script is complete.  I've seen the script for a progress bar using an explorer progress display, however in my script i'm updating IE so i think there might be conflict there.  I haven't tried it yet, but I will definitely try, but if anyone has any ideas or script that will display a message for the duration of my code that would be great.  thanks.
 
 
Post #: 1
 
 RE: Progress Bar without using IE - 7/22/2005 7:25:07 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
I have gotten good results using JsProgBr.exe:

http://www.jsware.net/jsware/scripts.html#prog

(in reply to jsou)
 
 
Post #: 2
 
 RE: Progress Bar without using IE - 7/22/2005 8:03:48 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
You can also use the Popup function:

Const NoButtonClicked = -1
intSecondsToWait = 10
strText  = "This Popup window will automatically close in " & intSecondsToWait & " seconds..."
strTitle = "Popup Example"
intType  = vbOKCancel + vbInformation   ' Values obtained from VBScript's MsgBox Constants.
Set oShell = CreateObject("WScript.Shell")
intButton = oShell.Popup(strText, intSecondsToWait, strTitle, intType)

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to jsou)
 
 
Post #: 3
 
 RE: Progress Bar without using IE - 7/22/2005 8:14:58 AM   
  Country73


Posts: 712
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
Here's another variation for what Snipah has already posted.

call popup(10)   
sub popup (waittime)
   sTitle="Removing... Estimated time needed " & waittime & " seconds."
   sMsg="To check time remaining, press OK." & vbcrlf
   set wshshell=createobject("wscript.shell")
   remaintime=waittime : starttime=now
   do while MyButton<>-1 and remaintime>0
       MyButton = WshShell.Popup(sMsg, remaintime, sTitle, 64-0)
       remaintime=waittime-datediff("s",starttime,now)
       if MyButton<>-1 then
           sMsg=sMsg & vbcrlf & "Time remaining : "& remaintime & " seconds."
       end if
   loop
   sTitle="Removal is complete."
   sMsg="Thank you for your patience!"
   MyButton = wshshell.popup(sMsg, 2, sTitle, 64-0)
   set wshshell=nothing
end sub

(in reply to Snipah)
 
 
Post #: 4
 
 RE: Progress Bar without using IE - 7/22/2005 8:26:21 AM   
  jsou

 

Posts: 24
Score: 0
Joined: 7/22/2005
Status: offline
Thanks guys, this is really helpful, but I don't exactly know the duration of my script.  I'm installing a bunch of programs and I want the message up while the programs are being installed.  Any suggestions?

(in reply to Country73)
 
 
Post #: 5
 
 RE: Progress Bar without using IE - 7/22/2005 8:58:44 AM   
  ehvbs

 

Posts: 2065
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Sample script to wrap:

Option Explicit      ''< Variablen müssen vor ihrer Verwendung deklariert werden

Dim nRounds
Dim nSecs

nRounds =  5
nSecs   =  2

Dim sTmp
Dim nIdx

sTmp = "progress tester started.  " & Now & " (nRounds = " & nRounds & " nSecs = " & nSecs & ")"
WScript.Echo sTmp

For nIdx = 1 To nRounds
    WScript.Sleep 1000 * nSecs
    sTmp = "progress tester working.  " & Now
    WScript.Echo sTmp
Next

sTmp = "progress tester finished. " & Now
WScript.Echo sTmp

script to display msgbox:

Option Explicit      ''< Variablen müssen vor ihrer Verwendung deklariert werden

MsgBox "Do not disturb!"
Do While True
   WScript.Sleep 1000000
Loop

Script to do the wrapping:

Option Explicit      ''< Variablen müssen vor ihrer Verwendung deklariert werden

Dim sFSpec
Dim sMsg

sFSpec = ".\pgt.vbs"
sMsg   =   "cscript pgw.vbs FSpec"           + vbCrLf _
         + "  FSpec: script to wrap"         + vbCrLf _
         + ""

If 0 < WScript.Arguments.Count Then
   sFSpec  = WScript.Arguments( 0 )
Else
   WScript.Echo sMsg
   WScript.Quit( 1 )
End If

Dim oFS
Dim oSH
Dim sFSpec2
Dim oCP
Dim oCM
Dim sCmd
Dim sTmp

Set oFS = CreateObject( "Scripting.FileSystemObject" )
Set oSH = CreateObject( "WScript.Shell" )

sFSpec  = oFS.GetAbsolutePathName( oSH.CurrentDirectory + "\" + sFSpec )
sFSpec2 = oFS.GetAbsolutePathName( oSH.CurrentDirectory + "\pgm.vbs" )
sCmd    = "cscript " + sFSpec
sTmp    = "wrapping " + sFSpec + " "
WScript.StdOut.Write sTmp

Set oCP = oSH.Exec( sCmd )
Set oCM = oSH.Exec( "cscript " + sFSpec2 )

Do While 0 = oCP.Status
   WScript.StdOut.Write Now
   WScript.Sleep 1000
   WScript.StdOut.Write String( 19, Chr( 8 ) )
Loop
WScript.StdOut.WriteLine Now
oCM.Terminate

sTmp =   "Output of wrapped script:" + vbCrLf _
       + String( 79, "-" )           + vbCrLf _
       + oCP.StdOut.Read( 10000000 ) + vbCrLf _
       + String( 79, "-" )
WScript.Echo sTmp



(in reply to jsou)
 
 
Post #: 6
 
 RE: Progress Bar without using IE - 7/22/2005 8:59:55 AM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
you can make two separate scripts, your script, and the script examples the other posters have put up for popups and what not, and put a command at the very beginning of your master script to call the progress bar script, and then another command at the end to end the progress bar script. You obviously would want to insert code in the progress bar script to display the appropriate messages, and put the appropriate code in your master script to kick off the appropriate sections of your progress bar script. I would imagine you would want to modify the posted scripts to use either functions or subs so you can call the appropriate sections in the progress bar in a controlled fashion.

(in reply to jsou)
 
 
Post #: 7
 
 RE: Progress Bar without using IE - 7/24/2005 9:15:01 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
Here is a progressbar that I have created.

1/ Create a file named ProgressBar.log

2/ Copy-paste the following code into ProgressBarFast.vbs


quote:

'---------by Fredledingue---------
'--------set constants--------
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Const OPEN_FILE_FOR_APPENDING = 8
Set fso = CreateObject("Scripting.fileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Title = "Progress"
'--------read from file-----------
Set f = fso.GetFile("ProgressBar.log")
Set ts = f.OpenAsTextStream(ForReading, Tristatefalse)
Execute ts.ReadAll
ts.Close
d = FormatNumber( Done / (sNum/100) +1 ,0,0,0,0)
Msg1 = String(d, "]") & String(100 - d, ".")
Msg2 = Done & "/" & sNum
Msg3 = "To stop the progressbar clic ""Cancel""" & VbCrlf & "Attention: This will not stop the process."
Do Until Done >= sNum
BtnCode = WshShell.Popup(Msg1 & VbCrlf & Msg2 & VbCrlf & Msg3, 1, Title, 1) '------to change the refresh speed: change the number after "Msg3,"
Select Case BtnCode
case 1 MsgBox "The progress bar will be back in one minutes.",,Title '------ok
WScript.Sleep 60000
case 2 MsgBox " " & _
VbCrlf & "Attention: The progressbar will disapear but the script process will continue." & _
VbCrlf & _
VbCrlf & "To stop the script process:" & _
VbCrlf & VbTab & "-Clic here on ""Ok"", then..." & _
VbCrlf & VbTab & "-Type Ctrl+Alt+Del." & _
VbCrlf & VbTab & "-Select ""Wscript"" in the task list. If several you will need to stop them all." & _
VbCrlf & VbTab & "-Clic ""End Task""." & _
VbCrlf & VbTab & "-Clic ""End Task"" one more time" & _
VbCrlf & VbTab & "-Repeat this operation until all the ""Wscript"" tasks have been terminated. ",,Title
wscript.quit
End Select
Set ts = f.OpenAsTextStream(ForReading, Tristatefalse)
Execute ts.ReadAll
ts.Close
d = FormatNumber( Done / (sNum/100) +1 ,0,0,0,0)
If d <= 100 Then
Msg1 = String(d, "]") & String(100 - d, ".")
End If
Msg2 = Done & "/" & sNum
'-----------check if progressing--------
Done1 = Done2
Done2 = Done
If Done2 > Done1 Then
Idletime = 0
Else
Idletime = Idletime +1
If Idletime = 45 Then
WshShell.Popup "Program not responding!",, Title, 0 + 16
End If
End If
Loop


3/ Take inspiration from this script demo to include the codeline necessary to run the progress bar into your script

quote:

'---By Fredledingue-------
'--------set constants--------
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
'---------number of items------------
sNum = 300 '------you will need to count how many items to process before
'--------write to progressbar report---------
Set Progress = fso.OpenTextFile("ProgressBar.log", ForWriting)
Progress.WriteLine "sNum = " & sNum
Progress.WriteLine "Done = 0 _"
Progress.Write "+0"
WshShell.Run "ProgressBarFast.vbs"
WScript.Sleep 250
'----------------------------------------------------
For i=0 To sNum
WScript.Sleep 50 '-------replace "sleep" by some operation here
Progress.Write "+1"
Next
Progress.Close
MsgBox "ok",,"Test"
'------------end of script sample---------

ProgressBarFast.vbs or ProgressBar.vbs , as well as ProgressBar.log must be included in the same directory as your script.

_____________________________

Fred

(in reply to jsou)
 
 
Post #: 8
 
 RE: Progress Bar without using IE - 7/25/2005 1:50:21 AM   
  mbouchard


Posts: 1856
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
You can also use AutoIT from www.hiddensoft.com which has a progressbar command.  AutoIT is a  scripting language that you can compile.  I have created a couple scripts in AutoIT that indicate Progress.  If you want to go this route let me know and I can post what I have.


Edited, corrected link.

< Message edited by mbouchard -- 7/25/2005 2:16:42 AM >


_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to Fredledingue)
 
 
Post #: 9
 
 RE: Progress Bar without using IE - 7/26/2005 12:41:24 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
If you're interested you can also use the command window to do this, but you would have to launch the script via cscript...

(in reply to mbouchard)
 
 
Post #: 10
 
 RE: Progress Bar without using IE - 8/31/2005 11:20:33 AM   
  jsou

 

Posts: 24
Score: 0
Joined: 7/22/2005
Status: offline
Sorry its been a while, but I am now looking for a way to do a simple progress bar in cscript that will output how much time is remaining for something.

(in reply to esnmb)
 
 
Post #: 11
 
 RE: Progress Bar without using IE - 9/1/2005 6:34:10 AM   
  Fredledingue


Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status: offline
This is a way (non tested) to calculate the remaining time

TimeElapsed = DateDiff("n", StartTime , Now())
TotalEstimatedTime = (TimeElapsed/Done)*NumberOfItems
TimeRemaining = TotalEstimatedTime - TimeElapsed


You can add this code to my progressbar script.
In my progress bar script replace "NumberOfItems" by "sNum".

I will publish a new version including this code and other stuffs in the "Post a code" forum as soon as I have tested it.

_____________________________

Fred

(in reply to jsou)
 
 
Post #: 12
 
 RE: Progress Bar without using IE - 12/9/2005 7:58:51 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
Sorry to dig up an old post but I figured out a way to do this when using cscript,
I put this in my loops i want to check the progress of,

dim progress
'clear the variable before starting
progress = ""
for each blah in blabbity
progress = progress & "."
'WScript.stdout.write doesnt add a newline so its a continuous line of dots
WScript.StdOut.Write progress
next

make sure youre using cscript or you'll be clicking ok alot lol

< Message edited by kirrilian -- 12/9/2005 8:00:02 AM >


_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to Fredledingue)
 
 
Post #: 13
 
 RE: Progress Bar without using IE - 12/11/2005 1:22:33 AM   
  ehvbs

 

Posts: 2065
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi kirrilian,

why do you accumulate the dots in 'progress'?

(in reply to kirrilian)
 
 
Post #: 14
 
 RE: Progress Bar without using IE - 12/11/2005 2:58:30 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Just by showing a sequence of dots does not tell anything about the overall progress, other than actions are taking place.  I have no idea if I am waiting to see ten dots or one hundred.  How would I extrapolate the progress from this?



Cybex

Edited for typo...

_____________________________

Common sense is not so common.

(in reply to kirrilian)
 
 
Post #: 15
 
 RE: Progress Bar without using IE - 12/11/2005 10:46:46 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
sorry i misunderstood, i thought progress was showing that actions are taking place. granted it isnt showing percent complete or anything, but this was meant to be a simple way of showing a user that "something" is happening. oftentimes there is no way to know what the total progress is going to be so i think its better to show that something is going on rather than just sitting there looking at a flashing prompt lol


_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to Cybex)
 
 
Post #: 16
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Progress Bar without using IE Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts