How hta Changed the Way I Deliver Builds - Part 5 - Check if Application is Installed

OK, we've now seen how we can add variables from the hta, start MicroStation and the other verticals and also add the cfg file we need to get the build running. It's time to add a bit more functionality to our hta, the first of these being a check on installation paths or if a package has been installed correctly. 
If you're like me you have started to install your CAD applications in custom locations. This has been a big help with some of the issues created with Windows 7, but also since the changes in where V8i installs it's workspace files. I'm NOT a big fan of files in all sort of locations so have started using C:\ Apps\Bentley\ as my base install path for my Bentley applications. It has other uses as well which I'll go into later on in thsi series. 

So, the way the hta is currently designed the start buttons stay back\active at all times. The issue here is what then happens is an application has not been installed or is installed in the wrong location? Well, you can add an 'if <variable path>.FileExists' series to a 'Sub Window_onload' code which will check to make sure the executable exists and in the correct location. 

'Sub Window_onload' is a very powerful piece of code when it comes to hta files. It basically means that each time the hta file loads or is refreshed, this piece of code runs. We'll look at some other functions that can be added to 'Sub Window_onload' later on, but to find out a bit more on this, check out: 

http://old.ict.nsc.ru/rus/docs/vbscript/unleashed/ch5.htmlhttp://msdn.microsoft.com/en-us/library/ms952648.aspx 

So, to check out that V8i SS2 has been installed correctly for my custom locations, I would use: 

if MSpath.FileExists("c:\Apps\Bentley\MS811_SS2\MicroStation\ustation.exe") then 
startv8ibutton.disabled=false 
else 
startv8ibutton.disabled=true 
end if 

The way this works, if you follow the code, is that is the file ustation.exe exists in the correct location then the button on the hta will remain active. If the file is not found then the button is greyed out telling the user that there is an issue that needs to be resolved. I've found this a great check for both install locations and to make sure software has actually been installed. If you, like me, have come into a big firm and don't have the time\resources to go through and fix existing machines, then you can set up a text file with install paths that the hta will search and match to the machine in use. We'll go through that another time as we build on the functionality of our hta file. 

Next, we'll look at one way in which you can actually lock out buttons for applications based on project. It's a really handy way of locking out applications you don't want users to access. 

More soon.

Anonymous