Now that you have a good looking application which does all you want, you probably need to share this application with your colleagues, friends or customer. You want your work simple to install from a server.
But there are too many files (css, htc, xml, xsl…), and if you create a new version, how can you update the old version already install in other computers.
Let’s reduce the number of files and embed the result in a “setup” file.
First Let’s “blend” all these files in one . We will embed the HTA files and all the dependency files as resources within a DLL or EXE. Then you will be able to call the HTA using a res:// protocol.
Beforehand you will have to modify your HTA slightly:
All of the dependencies files must be in the same folder as your HTA.
This means that if you had folders with files (like the images) you should remove them physically and of course in your HTA
One important point to know: the binary file must be a WIN 32 file. The resources in .net binary files are not managed the same way and cannot be accessed by MSHTA using the protocol res://.
Everything is ready. Create an empty project win32 DLL and add all the files of your HTA as type 23 resources and compile. Call your HTA using the res:// protocol. It will maybe not work directly and you will have to correct some UI but it is worthy of.
Now for the deployement let’s create a MSI, a Windows Installer file which will install your product on the customer computer correctly.
Install Wix on your computer. I prefer to use Wix 3.0 (beta). It will add Wix project wizard to visual studio.
Create a Wix project which will install the dll file and a shortcut. Remember that the sortcut must call "res://<path>/<file>.dll/comment.hta".
I willl not show you exemples because Wix API might change but you can find exemples on the the Wix Wiki.
After you ompile you will have a MSI that you can deploy using SMS, active directory or simply in a UNC folder .
I hope you liked reading this article.
Don’t hesitate to comment or send me remarks and questions.
Farewell and welcome to the wonderful world of scripting.