You are on page 1of 7

How to send a HTA (HTML) pop-up message to workstations

This document will demonstrate how to push out a detailed and professional looking message box to all active clients. This process can be used to send out outage announcements or even company announcements.

Things you will need

Nullsoft Scriptable Install System - Additional Information -

Files needed
LDMsgBox.hta HTML File that is displayed to the user LDMsgBox.ico Icon file that is used in the compiled message box application Cleanup.vbs VB Script that is used to remove all files after the form is closed LDMsgBoxImages Folder to store images in LDMsgBoxImages\blank.gif Image used in the form to create transparent space LDMsgBoxImages\header.jpg Image used as a header, you can replace this with a company logo LDMsgBox Script.nsi Nullsoft compiler code. This document specifies which files to be compiled

Preparing the message box content

The message box is created by a HTA file (HTML Application). HTA files are just HTML based documents with some kind of scripting language inserted in the document. These documents can be modified with Notepad, or even an HTML editor such as Dreamweaver. I normally create a blank HTML file and when I am satisfied with the design I will rename the .HTML (.htm) file to an .HTA file.

Below is a sample of an .HTA file. I will do my best to break this down, but to be honest its very easy to understand once you start using it and modifying the file. I have also provided a link at the beginning of this document that provides information on what HTA settings there are and how they can be controlled. *********************************************************************************** This section defines how the application looks and works. It includes HTA variables as well as HTML variables for the document. <head> <title> </title> <HTA:APPLICATION APPLICATIONNAME="IT Support Center Notification" BORDER="thin" BORDERSTYLE="raised" SCROLL="no" SINGLEINSTANCE="yes" CAPTION="yes" SYSMENU="no" SHOWINTASKBAR="no" contextMenu="no" SELECTION="no" windowState="normal" > <style type="text/css"> <!-body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; } body { margin-top: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; } .style2 { font-size: 8pt; font-weight: bold; } --> </style></head> *********************************************************************************** *********************************************************************************** This section is the scripting portion of the document. Each specific action of the application is split in to Sub Functions. Sub Window_OnLoad sets the size of the window and centers the window on the users primary screen Sub CloseButton is called from the HTML code and is used to close the window as well as calling a cleanup script (VBS) that will remove all the files that pertain to the message box. <script language="VBScript"> Sub Window_OnLoad window.resizeTo 800,440 intTop = (screen.height - document.body.clientHeight) / 2 intLeft = (screen.width - document.body.clientWidth) / 2 window.moveto intLeft,intTop End Sub Sub CloseButton

strComputer = "." Set objShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") strPath = objFSO.GetAbsolutePathName(".") strCleanup = "wscript " & Chr(34) & strPath & "\Cleanup.vbs" & Chr(34) If objFSO.FileExists(strPath & "\Cleanup.vbs") Then objShell.exec(strCleanup) self.close() Else self.close() End If End Sub </script> *********************************************************************************** *********************************************************************************** The section is the HTML portion of the document. The HTML code can be modified either in Notepad or a HTML editor such as Dreamweaver. As you modify the HTML code please be aware of the size of the document as you may have to update the size of the form in the Window_OnLoad Sub at the beginning of the document. <body STYLE="font:14 pt verdana; color:003366"> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><img src="LDMsgBoxImages/header.jpg" width="800" height="72" /><br /> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><strong>Service Outage for the Data Center - Monday, December 15th, 2008 10:00AM to 4:00PM PST<br /> <br /> </strong> <p>In a continuous effort to maintain and improve the operation of our Information Systems, a service outage for the Data Center has been scheduled for <strong>Monday, December 15th, 2008 10:00AM to 4:00PM PST</strong></p> <ul type="disc"> <li><strong>Reason For The Down Time: </strong>Hardware Maintenance</li> <li><strong>What is Affected: </strong>Access to all E-mail related services</li> <li><strong>Duration: </strong>Approx. 6 hrs. (10:00 AM - 4:00 PM PST.) </li> <li><strong>Groups Affected: </strong>All employees accessing E-mail related services.</li> </ul> <p>If you have any questions or need assistance after service has been restored, please contact the IT Dept.</p> <p>IT Dept<br /> <a title="" href=""></a><br /> Toll Free: 555.123.4567<br /> <br /> <span class="style2">Supervisors/Managers - Please share this communication with employees who do not have access to e-mail or a computer.</span></p> </td> </tr> <tr> <td valign="top"><div align="left"><img src="LDMsgBoxImages/blank.gif" width="18" height="16" /></div></td> </tr> <tr> <td valign="top"><div align="center"> <input type="button" value="Close" name="close_button" onClick="CloseButton"> </div></td>

</tr> <tr> <td valign="top"><img src="LDMsgBoxImages/blank.gif" width="18" height="16" /></td> </tr> </table></td> </tr> </table> </body>

The Cleanup.vbs file

The Cleanup.vbs file is used to remove all the files that the pop-up message package creates. On Error Resume Next Set objFSO = CreateObject("Scripting.FileSystemObject") strComputer = "." strPath = objFSO.GetAbsolutePathName(".") wscript.sleep 5000 objFSO.DeleteFile Wscript.ScriptFullName objFSO.DeleteFile strPath & "\LDMsgBox.hta",TRUE objFSO.DeleteFolder strPath & "\LDMsgBoxImages",TRUE wscript.quit

Preparing the NSIS package

The use of the Nullsoft Scriptable Install System is definitely not needed nor required. I use it to keep everything in one tiny package, this way I know everything is delivered to the client. The .NSI file is a text file that contains all of the package contents. Below is a sample of the document. # The application is extracted to the %appdata% folder. This is done to hopefully allow it to # duck under AntiVirus applications. # !define PRODUCT_NAME "LDMsgBox.exe" !define PRODUCT_VERSION "2.0a" SetCompressor lzma Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "LDMsgBox.exe" InstallDir "$APPDATA" Icon "LDMsgBox.ico" SilentInstall silent RequestExecutionLevel admin Section "MainSection" SEC01 SetOverwrite try SetOutPath "$INSTDIR\LDMsgBoxImages" File "LDMsgBoxImages\blank.gif" File "LDMsgBoxImages\header.jpg" SetOutPath "$INSTDIR" File "Cleanup.vbs" File "LDMsgBox.hta" Exec 'mshta.exe "$APPDATA\LDMsgBox.hta"' SectionEnd If you are going to use the NSIS package make sure you have installed the compiler that is linked in the beginning of this document. To compile the script right click on the .NSI file and select Compile NSIS Script.

Preparing the Distribution Package

Open the Console and select Tools | Distribution | Distribution Packages Select Public Distribution Packages Click the New Distribution Package icon in the upper left hand corner of the Distribution Packages window. Select New executable package from the list. Name the package and give it a description. Under Primary file browse to the location of the LDMsgBox.exe.

Click the Save button to save the package

Configure a Delivery Method

For the purpose of this document a Push Delivery is going to be used. I will be using the pre-built method provided. Select Tools | Distribution | Delivery Methods Expand the Public delivery methods section Select Push Double-Click on the Standard Push Distribution delivery method

Since this is a pre-built delivery method, please verify the settings on the following sections before use. Network Usage - Verify Use download from source to deploy files is selected Reboot - Verify Never Reboot is selected.

Configure a Scheduled Task

Select Tools | Distribution | Scheduled Task Click the Create Software Distribution Task icon in the upper left hand corner of the Scheduled Tasks window. Name the scheduled task. Select the Distribution Package within the task window and select the package created earlier in this document. Select the Delivery Method within the task window and select Push as the delivery type. Select Standard push distribution as the Delivery Method. Click Save.

Distribute the package via query

Note: For this example the message will be sent to workstations in a specific location. Right-Click on Public Queries and select New Query. Name the query Irvine Computers. Under the Machine Components section scroll down to Computer Location Select Computer Location and then select the Like operator. Enter Irvine in the Edit Values section Click Insert from the middle section of the query builder.

Click Save.

Drag the query to the scheduled task that was created earlier in this document. Right-Click on the scheduled task and select "Start Now".