Skip to content

Instantly share code, notes, and snippets.

@simply-coded
Last active July 21, 2024 05:33
Show Gist options
  • Save simply-coded/4c031021277ece15b53c1603fba2675c to your computer and use it in GitHub Desktop.
Save simply-coded/4c031021277ece15b53c1603fba2675c to your computer and use it in GitHub Desktop.
Simple vbscript timed message box using embedded hta.
'***********************
'Name: Timed Messages
'Author: Jeremy England
'Company: SimplyCoded
'Version: rev.001
'Date: 1/02/2015
'***********************
Option Explicit
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objSHL : Set objSHL = CreateObject("Wscript.Shell")
TimedBox "Welcome to Jeremy's Script.",4000,"by SimplyCoded"
'Setup Process
'------------------------------------------------------------
Function TimedBox(boxMessage, boxTime, boxTitle)
Dim tempFolder : Set tempFolder = objFSO.GetSpecialFolder(2)
Dim tempFile : tempFile = objFSO.GetTempName() & ".hta"
With tempFolder.CreateTextFile(tempFile)
.WriteLine "<html><HTA:APPLICATION SysMenu=""no"" Scroll=""no"" Border=""dialog"">" & _
"<head> <title>" & boxTitle & "</title> <script language = ""VBScript"">"
.WriteLine "Sub Window_OnLoad"
.WriteLine "window.moveTo 550,280"
.WriteLine "window.resizeTo 250, 130"
.WriteLine "idTimer = window.setTimeout(""PausedSection""," & boxTime & ", ""VBScript"")"
.WriteLine "End Sub"
.WriteLine "Sub PausedSection"
.WriteLine "window.close"
.WriteLine "End Sub"
.WriteLine "</script></head><body><p align=""center""> " & boxMessage & "</p></body></html>"
.Close
End With
objSHL.Run tempFolder & "\" & tempFile, 1, True
objFSO.DeleteFile tempFolder & "\" & tempFile
End Function
'------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment