How hta Changed the Way I Deliver Builds - Part 10 - Run Your Own Scripts

On the whole, I've been pretty lucky to have a good relationship with different IT groups, but on occasions I've had to work around groups who just don't want to work closer with the CAD Systems group. This means finding ways to run some of the login script functionality that I have in place.

In the end I've added this to the hta file functionality as well. We'll go through what the login scripts themselves do on another occasion, but to run a batch file when the hta loads, you could add something like the following to the start of the 'Sub Window_onload':

WshShell.Run chr(34) & "R:\Admin\Scripts\std_cad.bat" & Chr(34), 0

You could make this more generic by adding the path as a variable, but I'll leave that to you.

So, we cad run them at start up, but what about when a hta closes or as it closes? Well, there is another sub function that we can use:

Sub Window_onBeforeUnLoad

What this does is run anything within the sub before the hta closes. This is great to run batch files before a hta closes and I use it to back up users files to the network. I'll go into that later, but the sub looks something like:

Sub Window_onBeforeUnLoad
WshShell.Run chr(34) & "R:\Admin\Scripts\copy_cad_user.bat" & Chr(34), 0
end sub

Again, you could make this generic with variables, but is a good starting point for you to have a play.

More soon.

Anonymous