Solved

Terminal progressbar in vbs vbscript

Posted on 2014-03-04
2
899 Views
Last Modified: 2014-03-07
This is a progressbar. The script is run with cscript.

progtressMax is defined outside the function and is global. For instance 30.
Function DisplayProgress(progressNumber)
	On Error Resume Next
	Dim percentDone, percentLeft, intCount
	'oShell.SendKeys "CLS + {ENTER}" 
	oShell.Run "cls" 
	progressCount = progressCount + progressNumber
	wScript.StdOut.Write("|")
	percentDone = round((progressCount / progressMax) * 100)
	For intCount = 0 To percentDone
		wScript.StdOut.Write(".")
	Next
	percentLeft = round(100-((progressCount / progressMax) * 100))
	For intCount = 0 To percentLeft
		wScript.StdOut.Write("_")
	Next
	wScript.StdOut.Write("|")
End Function

Open in new window


The problem is that I am not able to clear the screen at the start of the function. So the progressbar floods the screen without making any sense.

Is there a better way to make a terminal progressbar? I don't want html and I don't want popups. Is there a way that works to clear the screen? Please don't post links to other pages of code unless you have tested and verified that it works. The above code for clearing does not work, and there are several examples out there of code that does not work.
0
Comment
Question by:itnifl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
sentner earned 500 total points
ID: 39903481
You don't actually need to clear the screen between every update, just move the cursor back to the beginning of the line.  

Remove the "cls" line (not needed).
Replace line 7 above with:
      wScript.StdOut.Write chr(13) + "|"

Do note that the terminal is only 80 characters wide by default, so you may need to do some extra math to make the maximum width of the bar fit in the window.
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 39912806
Yes, you are right.
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

623 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