Recently, I wanted to detect the Silverlight version for one of my on going R&D. I wanted to detect the version from batch file and depending upon that I wanted to execute one file. Searching over internet I came to know that, HTML Application has some additional power for execution of any local file as it runs under fully trusted mode. I did more research on HTA files and successfully completed my basic analysis.
What is HTA file?
Detecting the Silverlight Version:
Here comes the power of .hta file. If you run the code inside the browser window, it will not be able to create the ActiveX object and will throw exception. To do this, you need to run the code in fully trusted mode and HTML application will do the tricks for you as it runs in full trust mode. You can write more condition inside it to check other versions.
Showing the Silverlight version:
Now, once you get the Silverlight version, what will you do? You need to show some message to the user. Create another script code. If the detected version comes as “–1”, there must be some error detecting the Silverlight plug-in.
Look into the code:
Here is the full code for your reference:
Hope this will give you some basic idea and based on that, you will be able to improve the detection logic. Share your feedbacks/suggestions to improve this logic.