When I sat down and designed the application I wanted to implement the following features:
- Separate the MOTD text into a text file, motd.txt, so that no one was actually modifying the HTA itself. This is also how my old kixtart one worked.
- Have it look for the motd.txt file in the same location as the HTA itself.
- Provide the ability to supply a command line argument to look for the motd.txt file on a common file share, such as the “netlogon” share on Domain Controllers, which would be “%LogonServer%\netlogon”.
- If the motd.txt file is missing, close the application. This is important, as it allows you to leave the HTA in place with the existence of the text file determining whether or not it runs.
- It was also important that the text from the motd.txt file is read in as it is typed. ie. No need to consider formatting, etc. To address this, my script simply appends a <BR> html tag to the end of each line. The <BR> tag provides a carriage return and line feed.
- I didn’t want multiple instances to run in the same user session at the same time. This can easily be controlled by using singleInstance property of the HTA Application.
- I didn’t want users being able to simply close or minimise the application. This can easily be controlled by using sysMenu property of the HTA Application. In fact, the only way for them to close the application is for them to accept that they have read and understood it. Unfortunately, if they have permission to do so, they can end the mshta.exe task from Task Manager. This may well be the case for some Desktop/Notebook fleets, but not on locked down Citrix/Terminal Servers.
It took me a while to get my head around the VBScript code for a few of the features I wanted to implement, as a HTML Application only supports pure VBScript and not the added commands I am used to using with the WScript/CScript Windows scripting host.
If you open a HTA using IE, you will get a security prompt. So to open the HTA silently without the IE security prompt you have two options:
- Associate .hta extensions with mshta.exe (Microsoft HTML Application host), the script host for a HTA, which is found in the %SystemRoot%\System32 folder. Then just double click or open the HTA itself.
- Simply launch it from the command line using mshta.exe in the syntax.
i.e. mshta.exe motd.hta
So if using command line parameters, you need to use quotes around them. For example:
mshta.exe motd.hta “netlogon”
If you read the Scripting Guy’s article, you will understand that the first argument is array member 3, second is 5, etc. But we are only concerned here with array member 3.Now I have the mechanism to launch the HTA via the two methods I was looking for in my design.
- mshta.exe motd.hta - This will look for the motd.txt file in the same location as the motd.hta.
- mshta.exe motd.hta “netlogon”- This will look for the motd.txt file in the %LogonServer%\netlogon share.
There are four ways that you can implement this:
- Chain or call it from an existing logon script.
- Add it as a Logon Script in a Group Policy Object.
- Add it to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run key on all computers.
- Add a shortcut to the “%ALLUSERSPROFILE%\Start Menu\Programs\Startup” folder on all computers.
Future enhancements:
- Log the acceptance to a file or registry before closing the application. This can provide some legal and compliance tracking if needed.
- Add the customers logo into the application. This is simple to do, but I need to consider where on the banner to locate the logo, and how I can construct some code that manages different size logos.
- Implement different messages based on Group Membership. Could be of value to different organisations. You can actually do this already using multiple Group Policy Objects. However, my idea was to implement this by using different group membership tags within the one motd.txt file that would expose different lines and paragraphs to users depending on their group membership. Probably more complex than it needs to be, but would make a nice feature.
5 Comments
Thanks - Tom
Cheers,
Jeremy.
The main aim of this task was to deploy it through a Group Policy, but I have considered all 4 methods documented in the article, so should therefore work. Admittedly, all 4 have not been tested. Please let me know if you run into a problem and what the issue is, and I’ll take a closer look.
Cheers,
Jeremy.
One Trackback/Pingback
Post a Comment