Can I embed an icon to a .hta file?

I’ve found an hack to set the icon.

Prepare an icon file icon.ico and an hta file source.hta with the following contents:

<HTML>
<HEAD>
   <SCRIPT>
      path = document.URL;
      document.write(
       '<HTA:APPLICATION ID="oHTA" APPLICATIONNAME="myApp" ICON="'+path+'">');
   </SCRIPT>
</HEAD>
<BODY SCROLL="no">
  Hello, World!
</BODY>
</HTML>

Open a command prompt and type:

copy /b icon.ico+source.hta iconapp.hta

That will concatenate the icon and hta into a single file.

In my test case Internet explorer skipped over the icon data and display the HTML correctly.

The path of the icon is then set to that of the .hta file itself using javascript and the icon is loaded.

I have tested this on Windows XP SP3, Internet explorer 8.

Leave a Comment