0

Our website includes a link where customers can download the latest update.exe files. We'd like to have the web page automatically display the file version info of each patch file. The files are digitally signed native windows executables.

Is there a way to get and display the version info from the files using HTML5 or javascript without having the user have to click a button? In essence, we want the file versions to update when the page loads or is refreshed. Here's what we have now. I'd like to add "Version 1.2.3.4" after where it says "Product" on each line.

<ul class="links">
    <li>Latest Patches:</li>
    <li><a href="updateFoo.exe">Update for Foo Product </a></li>
    <li><a href="updateBar.exe">Update for Bar Product </a></li>
    <li><a href="updateYou.exe">Update for You Product </a></li>
</ul>
Michael
  • 401
  • 5
  • 16
  • This will require each file downloaded to the client side, and cost bandwidth to the user and your server. Would be better if you fetch the version number from the client side and then insert into the page HTML content. – vishva8kumara May 04 '17 at 20:52
  • What is the server side scripting language, and with what the files are compiled and build with. I assume the build tool matters in this case. – vishva8kumara May 04 '17 at 20:53
  • Wouldn't it be easier to fetch the version number from your build system or repository itself.. – vishva8kumara May 04 '17 at 20:53
  • We are trying to avoid having to edit the HTML page every time we upload a new patch file. Our build system can put the files up there. But we can't edit the HTML automatically. Since the files reside on the server, is there no way to extract the version information directly from the file and display it on the web page? We are also open to using another method. The thing we want to avoid is having to edit the HTML every time a patch is uploaded. – Michael May 04 '17 at 21:38
  • You could use a server side scripting language such as php or ASP (or ASP.net) to generate and return an HTML page through web server, so you do not have to manually edit the HTML page. – vishva8kumara May 05 '17 at 06:33
  • To get an exe version info in php is explained in first answer to this question: http://stackoverflow.com/questions/41228319/extract-internal-exe-info – vishva8kumara May 05 '17 at 06:42
  • To do that at the client side using JavaScript is not impossible, but not a good idea since the JavaScript would have to download (at least) first few chunks of each file every time the page loads. – vishva8kumara May 05 '17 at 06:44
  • The PHP solution sounds like it would work. Can you call a PHP function inline in the existing HTML to generate just the elements I need for the version? The rest of the page is actually generated with Jekyll and has some other content that changes occasionally. – Michael May 05 '17 at 14:10
  • First you have to see if your server supports php. Then make the html page to a php file. You can put any HTML content in a php file. When you want to call a php function, enclose that in , and the result of that php part will be put into its place. – vishva8kumara May 06 '17 at 07:51
  • If you want to keep the html page intact, you can call a seperate php file via Ajax to get the version number of each exe. – vishva8kumara May 06 '17 at 07:51

1 Answers1

0

It would be better to find the file version at the server side. If you do it at the client side, JavaScript would have to download at-least the first few chunks of each file.

If you want to keep the HTML file intact, you can make Ajax requests to server side where a server side script such as php file will return file version for each of these files. An example for such a php function can be found here: Extract internal EXE info

Following example shows how you can fetch file versions via Ajax from server side and write next to each download link.

<script src="https://raw.githubusercontent.com/vishva8kumara/arc-reactor/master/arc.js"></script>

<ul class="links">
    <li>Latest Patches:</li>
    <li><a href="updateFoo.exe" class="fetchVersion">Update for Foo Product </a></li>
    <li><a href="updateBar.exe" class="fetchVersion">Update for Bar Product </a></li>
    <li><a href="updateYou.exe" class="fetchVersion">Update for You Product </a></li>
</ul>

<script>
    var links = q('.fetchVersion');
    for (var i = 0; i < links.length; i++)
        new ajax('getVersion.php?file='links[i].getAttribute('href'),
            {
                callback: function(data, ref){
                    ref.appendChild(elem('span', data.responseText));
                }
            }, links[i])
</script>

And on the server, create a file getVersion.php that accepts $_GET['file'], call the getFileVersionInfo function and writes the file info to the output buffer.

Community
  • 1
  • 1
vishva8kumara
  • 353
  • 1
  • 3
  • 15