Mini123 Posted July 15, 2006 Posted July 15, 2006 Hey guys,I have made a VBS that will run an application then tab its way through the options to start a scan of my system off.I am after a box or a notice or something that will sit on my screen telling me how long it has left (How long the VBScript has left not the program itself)I have used the WScript.Sleep 1800000 so my machine will allow 30minutes for the scan to complete and then tab through the options again to close the program.Because i know the VBScript it is set to last for 30 minutes then close the program and end the script i know that it wont go over that does anyone know of any VBScript code that will allow me to have a timer somewhere on the screen that counts down from 30:00 Minutes when the script is run?Thanks alot
gunsmokingman Posted July 15, 2006 Posted July 15, 2006 You would have to use a HTA with the VBS script inside of it to do that.Here is a example HTA, that will countdown from 10 second then when it finished will close it self.<HTML><HEAD> <HTA:APPLICATION ID = "CountDown Demo_V1" APPLICATIONNAME = "CountDown Demo_V1" BORDER = "thick" CAPTION = "Yes" SHOWINTASKBAR = "Yes" SINGLEINSTANCE = "Yes" SYSMENU = "Yes" WINDOWSTATE = "normal" VERSION = "1.2.1" INNERBORDER = "yes" SELECTION = "yes" MAXIMIZEBUTTON = "No" MINIMIZEBUTTON = "Yes" NAVIGABLE = "yes" CONTEXTMENU = "yes" BORDERSTYLE = "normal" Icon = "%SystemRoot%\Explorer.exe"> <Title>Count Down Demo</Title> <!-- ================== --> <!-- BODY STYLE NORMAL--> <STYLE type="text/css"> Body.Normal { font: 10.25pt Verdana; color:#000080; font-weight:bold; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#86cceb',endColorStr='#5589ab'); padding-top:1; padding-bottom:1; Text-Align:; } </STYLE> <!-- TABLE STYLE NORMAL--> <STYLE type="text/css"> Table.Normal { font: 8.25pt Verdana; color:#000080; font-weight:bold; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#E9E9E9',EndColorStr='#9E9E9E'); padding-top:1; padding-bottom:1; Text-Align:; vertical-align:; } </STYLE> <!-- TD STYLE MENUNORMAL --> <STYLE type="text/css"> TD.MenuNormal { font: 8.25pt Verdana; color:#000080; font-weight:bold; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#eeeeee',EndColorStr='#5e9ab9'); padding-top:1; padding-bottom:1; Text-Align:; vertical-align:; cursor:Hand; } </STYLE> <script language="VBScript"> '/-> RESIZE THE HTA WINDOW AND POSSITION IT window.resizeTo 325,225 : window.moveTo 170,195 Dim Act : Set Act = Createobject("Wscript.Shell") Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim SD : SD = Act.ExpandEnvironmentStrings("%SystemDrive%") '/-> SET THE AMOUNT OF TIME YOU WANT THE SCRIPT TO RUN HERE Dim CountDown : CountDown = 10 '/-> HTA CAN NOT USE WSCRIPT.SLEEP THIS IS A WORK AROUND Function Rst1() Dim Ts : Set Ts = Fso.OpenTextFile(SD & "\Rest1.vbs", 2, true) Ts.WriteLine "Wscript.sleep 1000" : Ts.close Act.run(SD & "\Rest1.vbs"), 0 , True : Fso.DeleteFile(SD & "\Rest1.vbs") End Function Function StartHta() Do CountDown = CountDown - 1 Text1.innerHTML = "Time Left " & chr(187) & Space(2) & CountDown '/-> PLACE YOUR SCRIPT HERE START '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '/-> PLACE YOUR SCRIPT HERE END Rst1() Loop Until CountDown = 0 window.close() Exit Function End Function </SCRIPT><Center> <Body Class='Normal' Scroll='No' OnLoad='StartHta'> <Table Class=Normal Width='250' > <TD Class=MenuNormal> <Span ID="Text1">Time Left </Span> <BR>Processing the script please wait</TD></Table> Some more text here is needed </Center>
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now