|
HTA in a nutshell
An HTA or HTML application is HTML code with a .hta file extension. It's a trusted application that uses mshta.exe to display the Internet Explorer object without the security restrictions of the browser.
External configuration file
Earlier versions of the Software Inventory Tool were self-contained and worked well from the Hartford site for which it was designed. The Software Exclusion List is a list of applications that are removed from the overall Add/Remove listing, which would contain many applications already installed by a base image, numerous Windows and Microsoft Updates, old device drivers, and applications or utilites installed by the user which we wouldn't be replacing.
I was asked by IBM to create single external text file that would allow easy updates to the Software Exclusion List, even though it wouldn't change from site to site, and changes to the site name and default printer path for use at other ING locations.
|
 |
Figure 1. A stripped-down example of the configuration text file gives an idea of how it's organized (much like a Windows dot ini file).. |
|
|
Reading the file, assigning values to global variables and building an array
The variables strSiteName, strSitePrinter and the array arrSWExclusionList are global variables and are used elsewhere in the script. After declaring some local variables in the ReadSiteConfigFile function, we first read the text file into a string strText, and then convert the string into an array arrTemp. Looking at the example text file in Figure 1, array elements 1 and 4 contain the values we need and those are assigned to strSiteName and strSitePrinter.
Next we need to cycle through each value in arrTemp looking for the tag [Software Exclusion List]. We then record the array element number of the following line and start counting the lines until we find an empty line. In the case of Figure 1, there's another section called [Not on Software Distribution], which was removed from the code listing in Figure 2 for simplification. Once again, we do the same and look for the tag, record the start point, count the number of lines till we encounter the next empty line.
In the final section, we build the arrays using the starting point arrTemp(intSWStartLine) for the number of lines that we counted intSWCount. Note the line ReDim Preserve arrSWExclusionList(i). Each time we increase the size of the array, we need to redeclare it with a ReDim. Preserve allows us to retain the existing values already in the array. Again, not shown, we do the same for arrNotInSWDist and we're done. We have 2 global string variables and 2 global arrays ready for use in other functions of our script.
|