password
username
Sponsored by CakeMail, an email marketing software.
Newsletter preview


In This Issue
- How to Learn and Even Master the Art of Writing HTAs
- For More Information

FYI: The articles presented in "How to Learn and Even Master the Art of
Writing HTAs" as well as the article "An 'Unkludgy' Way to Back Up Files"
that's discussed in "For More Information" will be open for public viewing
through June 2.

/* ==================================== */

:: **** How to Learn and Even Master the Art of Writing HTAs ****

HTA stands for HTML Application, but it could very well stand for Hip &
Trendy Application. Although HTAs have been around since Microsoft Internet
Explorer (IE) 5.0, they've become increasingly popular in the past couple of
years--and for good reason. HTAs offer all the features of Web pages yet they
aren't subject to the same security constraints because they run as trusted
applications. Plus, HTAs come with their own object model, giving them
functionality (i.e., control over UI design and access to the client system)
that isn't available in Web pages.
Although HTAs are a hot commodity, they might make you hot under the
collar when you're trying to learn to write them. So, I'm going to highlight
some resources that novice HTA writers will likely find helpful. In addition,
I'll point out some resources that more advanced HTA writers can use to
expand their HTA writing skills. Finally, I'll provide links to HTAs that
scripters have written so that you can learn from their code.

The Basics
Before you start learning to write HTAs, you should take a look at
Microsoft's "Introduction to HTML Applications (HTAs)" tutorial, which you
can find on the MSDN HTML Applications Web page at
http://pentonmedia.whatcounts.com/t?ctl=56C79:6B7D3383C3CE94442F2CA7D18295462A .
The section titled "The Power of Trust: HTAs and Security" discusses the
security specifics, including the fact that you need to take the same
security precautions with HTAs as you would with any executable. The tutorial
also has a section titled "Creating an HTA," but I don't recommend spending
much time reading it. It contains little useful information.
A much better article to start with is "Hooked on HTAs" at
http://pentonmedia.whatcounts.com/t?ctl=56C69:6B7D3383C3CE94442F2CA7D18295462A .
This article presents the basics, such as the HTA structure and coding
elements. It also demonstrates how to create a simple input screen that has
two input fields and two buttons.
The article "Use an HTA as a UI for Your VBScript Scripts" at
http://pentonmedia.whatcounts.com/t?ctl=56C6E:6B7D3383C3CE94442F2CA7D18295462A
builds on the information that "Hooked on HTAs" provides by showing you how
to set up more-versatile UIs. You can learn how to create UIs that feature
such elements as textboxes, password boxes, single-select list boxes,
multiselect list boxes, radio buttons, On Change selection combo boxes, and
check boxes.
Microsoft TechNet Script Center's HTA Developers Center at
http://pentonmedia.whatcounts.com/t?ctl=56C78:6B7D3383C3CE94442F2CA7D18295462A offers a
two-part series "Creating Your Own HTAs" for novices. (Apparently, a third
part will be coming eventually.) The center includes a link to the HTA
Helpomatic utility. Microsoft designed this utility to lend assistance on two
fronts. Besides helping you initially create an HTA by offering sample
VBScript and HTML code, you can use this utility to test any modifications
you make to that HTA after you've written it. The HTA Developers Center also
includes links to the HTA, HTML, and Dynamic HTML (DHTML) object models. The
link to the HTA reference sends you to the MSDN HTML Applications Web page,
which in turn, includes links to documentation about the HTA:Application
object and its various attributes/properties.

Beyond the Basics
After you have the basics behind your belt and you're ready to expand
your HTA skills, check out "HTA F/X" at
http://pentonmedia.whatcounts.com/t?ctl=56C77:6B7D3383C3CE94442F2CA7D18295462A .
This article discusses how to apply special effects to your HTAs. You can
make cursors come alive with animation, magically change text without
touching it, make text slowly fade in and fade out, make items quickly
disappear and reappear, and more. The MSDN Introduction to Filters and
Transitions Web page at
http://pentonmedia.whatcounts.com/t?ctl=56C7A:6B7D3383C3CE94442F2CA7D18295462A
is also helpful if you want your HTAs to have a little pizzazz. This Web page
explores how you can use IE's filters and transitions with basic scripting to
create visually engaging and interactive documents.
The HTA Developers Center at
http://pentonmedia.whatcounts.com/t?ctl=56C78:6B7D3383C3CE94442F2CA7D18295462A
includes links to a series of six articles for the more advanced HTA writer.
Those articles are
- "Add a Gradient Background to Your HTAs"
- "Add Color to a List Box"
- "AutoRefresh an HTA Using a Timer"
- "Create an HTA Without a Title Bar"
- "Run a Script From a Text Link"
- "Use a File Open Dialog Box to Populate a List Box (Windows XP-only)"

HTAs in Action
Sometimes it's helpful to check out HTAs that other people have written.
You can see how they coded a particular task or UI feature, or you can adapt
the code for your own use. Alternatively, you might want to check the
following HTAs to see whether they'd be useful in your job:
- AddColor.hta: Runs demos showing how to add color to HTA and VBScript
reports as well as provides a way for you to enter color values and see the
results.
nla_internal_1279155.jpg
- CheckProcess.hta: Monitors crucial processes on a local or remote
computer.
http://pentonmedia.whatcounts.com/t?ctl=56C72:6B7D3383C3CE94442F2CA7D18295462A
- CSVviewer.hta: Lets you quickly and easily view comma-separated value
(CSV) files.
http://pentonmedia.whatcounts.com/t?ctl=56C74:6B7D3383C3CE94442F2CA7D18295462A
- EventLogQueryUtility.hta: Retrieves errors, warnings, and/or audit
failures from the event logs on one or more computers for the specified
number of days.
http://pentonmedia.whatcounts.com/t?ctl=56C6A:6B7D3383C3CE94442F2CA7D18295462A
- GetADsPath.hta: Returns the ADsPath strings of Active Directory (AD)
objects when you enter an object's name (CN, sAMAccountName, or GroupName
attribute).
http://pentonmedia.whatcounts.com/t?ctl=56C73:6B7D3383C3CE94442F2CA7D18295462A
- Install_Printer.hta: Makes installing printers on a print server easy
and consistent by using the PrinterAdmin (prnadmin.dll) tool to create the
printer port, share the printer, publish it to AD, and record the printer
information in the printer's properties page.
http://pentonmedia.whatcounts.com/t?ctl=56C71:6B7D3383C3CE94442F2CA7D18295462A
- Install_Service.hta: Installs a script as a service so that you can
run the script as a service.
http://pentonmedia.whatcounts.com/t?ctl=56C70:6B7D3383C3CE94442F2CA7D18295462A
- ReadFile.hta: Opens the specified file and displays the file's contents
on the page.
http://pentonmedia.whatcounts.com/t?ctl=56C6F:6B7D3383C3CE94442F2CA7D18295462A
- SuperTuesday.hta: Displays the first to the fifth occurrence of any day
of the week in any given month (e.g., display the fourth Monday in May) or
for up to 72 months (e.g., display the fourth Monday for the next 12 months).
http://pentonmedia.whatcounts.com/t?ctl=56C75:6B7D3383C3CE94442F2CA7D18295462A
- UserQuotaUtility.hta: Lets you set and display disk quotas on local and
remote Windows Server 2003 and Windows XP computers.
http://pentonmedia.whatcounts.com/t?ctl=56C6C:6B7D3383C3CE94442F2CA7D18295462A
- Winutil.hta: Retrieves information about the local computer's startup
commands, OS (including service pack data), and BIOS.
http://pentonmedia.whatcounts.com/t?ctl=56C76:6B7D3383C3CE94442F2CA7D18295462A

To view the code behind the HTA, you need to open the HTA in a text editor
such as Notepad. Alternatively, if you have the HTA running, you can
right-click and select View Source from the menu that appears.

:: **** For More Information ****

If you enjoyed reading "How to Learn and Even Master the Art of Writing
HTAs," you might be interested in learning where you can get more of this
type of content. That article was initially published in Scripting Pro VIP
Update, a monthly email newsletter sent to Scripting Pro VIP subscribers.
Scripting Pro VIP Update doesn't contain any advertising, so there is more
room for informative content such as "How to Learn and Even Master the Art of
Writing HTAs."
Scripting Pro VIP offers much more than an email newsletter. Each week, a
new scripting article is posted on the Scripting Pro VIP Web site. Unlike
other articles and code you might find on the Web, the articles and code
you'll find on the Scripting Pro VIP site go through extensive technical
editing and testing. To let you know about and quickly access newly posted
articles, you can receive an email or RSS notification that contains a link
to the article.
Besides offering tried-and-tested articles, Scripting Pro VIP offers
personal service that you can't get anywhere else on the Web. For example,
the Scripting Pro VIP Web site includes a subscribers-only "Ask the Editor"
feature that gives readers a direct line to the editor. For example, one
Scripting Pro VIP reader created a batch file to back up a database. However,
he knew that the batch file was a kludge, so he wanted to write a better
script. Curious as to how a scripting pro would go about it, he contacted the
Scripting Pro VIP editor. The result is BackupFile.vbs, which is discussed in
the article "An 'Unkludgy' Way to Back Up Files" at
http://pentonmedia.whatcounts.com/t?ctl=56C6B:6B7D3383C3CE94442F2CA7D18295462A .
To learn about some of the other benefits of subscribing to Scripting Pro
VIP and a special offer, go to
http://pentonmedia.whatcounts.com/t?ctl=56C68:6B7D3383C3CE94442F2CA7D18295462A