HTA – Manage a dynamic Drop Down List content through a txt file

Continuing our saga of building HTA’s (in fact, it consists in a great way to help us in many deployment cases) it could be very useful in some specific cases, if we’ve a need to usually change the data of drop down list (ddl)? Is it much easier (and cleaner!) if you deliver a txt file to the customer and he only need to manage in a simple way to add or change the content of it drop down lists? Confused?! The following example could be useful to better understand that.

I’ll use for this example a previous post of this blog (https://deploymentlab.wordpress.com/2014/07/06/create-hta-for-winpe-to-set-keyboard-layout-and-protect-task-sequence-with-a-password/). It could be easier if we could add more “languages” of our ddl through some txt file, right? And it will be also easier to manage a txt file, instead of have to edit the script always you want to change something on it.

Untitled001

So, let’s back to this part of HTA (built on the the previous post), and show an easier way to manage this through a txt file.

The following example is a simplest option in HTA. On that, the options are available “hardcoded”, so if you want to add a new option (language in this case), we’ll need to open the script, find the line of the specific drop down list and edit the content, and save the script.

Untitled002

Our purpose consists of create a drop down list with no options, as the following image shows.

Untitled003

To redirect the content of this drop down list to an external text file, there is some lines that should be added of the HTA, as the image below shows:

Untitled005

The “txt file” part is really the most easiest to make. Just have to build a text file and make it on that way: TEXT;VALUE

Untitled004

Note: Separate the TEXT and the VALUE with a “;” because it is assigned on the script to support it on that way.

The vbscript will read all content of the text file and “post it” on the drop down list.

In further situations that you want to add a language (ex: Sweden), you only have to add it on the text file. Simpler right? 🙂

 

Enjoy your deployments!

/Fabio

Leave a comment