Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Days Left Timer VBS

0.00/5 (No votes)
29 Jun 2010 1  
Days Left Timer VBS self deleting

What It Does

It's a Visual Basic Script that lets System Administrators notify users of an upcoming event or change and how many days are left until the change. After it has hit zero days left, it deletes itself. This can be changed so it gives a second message before it deletes itself or launches other programs if required.

How to Use It

Place in start-up folder on Windows machines after modifying the message box and the eTime variable to what you want.

Code

sTime = Date()
'Change date to what ever you want in MM/DD/YYYY format
eTime = "10/10/2010" 

call datediffToWords(sTime, eTime)
Function datediffToWords(d1, d2) 
	report = ""
 	days = DateDiff("d",d1,d2)
	report = days & " Day(s)"
	datediffToWords = report
	Msgbox "Message "& datediffToWords,4160,"Title"
	If datediffToWords = "0" & " Day(s)" Then
		DeleteSelf
	End If
End Function 
Sub DeleteSelf()       
        Dim objFSO
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        objFSO.DeleteFile WScript.ScriptFullName
        Set objFSO = Nothing
End Sub 

Notes

To use in a web page, remove the messagebox and replace it with document.write and remove the DeleteSelf sub.

History

  • 29th June, 2010: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here