Search code examples
vbscriptpopupmessageboxcountdown

VBScript to Display Countdown using Vbscript Graphical Elements


I wanted to display a MessageBox which displays countdown from 10 to 1 and autocloses after 10 seconds. As Msgbox in vbscript passes code execution untill the user acts on it i tried it using Popup in Wscript Shell Object

Dim counter
Dim oShell
counter = 10
Set oShell= CreateObject("Wscript.Shell")
While counter > 0

oShell.Popup " Left " & counter & " Seconds",1,"Remind"
counter = counter-1
Wend

But it auto-closes for every second and opens a new popup is there any way i can display the countdown and autoclose using the available GUI elements in vb script


Solution

  • Afraid not, the popup is modal & can't be interacted with while its displayed so there is no way to update its existing content.

    If you want a more flexible UI you will need to use something different, the console or HTML in an HTA.