Через Internet Explorer
Set objExplorer = CreateObject(\"InternetExplorer.Application\")
Initalize(\"Test\")
for i=0 to 100
Call total(i,\"something\")
wscript.sleep 100
next
for i=0 to 100
Call current(i,\"process\")
wscript.sleep 100
next
destroy()
sub Initalize(sTitle)
objExplorer.Navigate \"about:blank\"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Left = 200
objExplorer.Top = 200
objExplorer.Width = 400
objExplorer.Height = 200
objExplorer.Visible = 1
objExplorer.Document.Title = sTitle
objExplorer.Document.Body.InnerHTML = \"Total: 0 % complete,
\"
objExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & \"Current Folder: 0 % complete, \" _
& \"
\"
end sub
sub total(intPercentComplete, sText)
objExplorer.document.getElementById(\"text1\").innerText=intPercentComplete
objExplorer.document.getElementById(\"msg1\").innerText=sText
objExplorer.document.getElementById(\"p1\").style.width=intPercentComplete*3
end sub
sub current(intPercentComplete,sText)
objExplorer.document.getElementById(\"text2\").innerText=intPercentComplete
objExplorer.document.getElementById(\"msg2\").innerText=sText
objExplorer.document.getElementById(\"p2\").style.width=intPercentComplete*3
end sub
sub destroy()
objExplorer.Quit
end sub
Прогресс-бар в консоли:
ForceConsole()
set oOUT = WScript.StdOut
oOUT.WriteLine \"test process: \"
For i = 1 To 100
Call progress(i, 100)
wscript.sleep 100
Next
Function printr(txt)
back(len(txt))
print txt
End Function
Function back(n)
Dim i
For i = 1 To n
print chr(08)
Next
End Function
Function percent(x, y, d)
percent = FormatNumber((x / y) * 100, d) & \"%\"
End Function
Function progress(x, y)
Dim intLen, strPer, intPer, intProg, intCont
intLen = 22
strPer = percent(x, y, 1)
intPer = FormatNumber(Replace(strPer, \"%\", \"\"), 0)
intProg = intLen * (intPer / 100)
intCont = intLen - intProg
printr String(intProg, ChrW(9608)) & String(intCont, ChrW(9618)) & \" \" & strPer
End Function
Function ForceConsole()
Set oWSH = CreateObject(\"WScript.Shell\")
vbsInterpreter = \"cscript.exe\"
If InStr(LCase(WScript.FullName), vbsInterpreter) = 0 Then
oWSH.Run vbsInterpreter & \" //NoLogo \" & Chr(34) & WScript.ScriptFullName & Chr(34)
WScript.Quit
End If
End Function
Sub print( sText )
oOUT.Write sText
End Sub
percent(x, y, d) - сколько процентов число x составляет от y с точностью d знаков
для запуска прогресс-бара = Call progress(x, y)