HEELPBOOK - VBScript - Sleep function (or Wait for few minutes) ########################### WScript provides a function called Sleep. You can use sleep function to pause the script for specified milliseconds. Yeah! all good. But I wanted to pause the script for few minutes (sometimes more than 30 minutes). Specifing 15 minutes in milliseconds means 900000, 30 minutes means 1800000 milliseconds. I didn't wan to deal with bigger numbers and didn't feel right. So I wrote a small subroutine to pause the script by specified minutes. Here it is and feel free use it. '********************************************************* ' Sub Routine: GoToSleep ' Parameters: Number of Minutes ' Purpose: Pause the script for specified minutes ' Written by: Anand Venkatachalapathy ' Date Written: July 1 2009 '********************************************************* Sub GoToSleep (iMinutes) Dim Starting, Ending, t Starting = Now Ending = DateAdd("n",iMinutes,Starting) Do t = DateDiff("n",Now,Ending) If t <= 0 Then Exit Do WScript.Sleep 10000 Loop End Sub '******* End of Sub Routine ************** If you really care how this subroutine works, read ahead. 1. Register the current time (Starting = Now) 2. Add the specified minutes to the current time and find the time after x minutes: Ending = DateAdd("n",iMinutes,Starting) 3. Do a "Do/Loop" loop till the current time is the "Time" after x minutes (see the Do Loop above). ############ ARTICLE INFO ############# Article Month: September Article Date: 15/09/2012 Permalink: http://heelpbook.altervista.org/2012/vbscript-sleep-function-or-wait-for-few-minutes/ Source: http://anandthearchitect.wordpress.com/2009/07/14/vbscript-sleep-function-or-wait-for-few-minutes/ Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook Follow us on Delicious: http://delicious.com/heelpbook Linkedin: http://it.linkedin.com/pub/stefano-maggi/27/73a/b20