Tip of the day, have a play with HTAs

New systems always tend to need new solutions and so has been the case with our shiny new wireless system, well I say shiny but the Ruckus kit is more of a matt white 😉

We re-deployed our pool of 15 laptops using RADIUS authentication (more on that in another post) so that we could provide enough kit for all students in some of our smaller rooms to get online should they need to. This was something we noticed being an issue last year with 20 students wanting to access Moodle via 8 PCs.

The setup works fine and gives exactly the same desktop experience apart from one thing… printing. Our fixed desktops use Group Policy Preferences to decide which printer to map via the computer’s OU. Great for kit that doesn’t move but doesn’t work very well with a trolley that can be moved around at will.

Time for plan b) then!

Some users didn’t need any help and found the Add Printer button, browsed the network and added the printer for the room they were in themselves. For the others we needed something simpler. First thought was how much I could do with VBScript… soon realised the answer in terms of a UI was… not a lot.

Then I remembered the joys of HTAs! I made a custom one a few years back for a kiosk-style system to  burn DVDs on demand so was wondering if I could do something similar but for mapping printers instead.

Initially I tried with the first example I found on Google; a radio button list. With 20+ printers to choose from it looked pretty awful, I soon realised a dropdown was the only sensible choice. A bit of tweaking later I have this…

Once the user clicks Add Printer the script maps the specified shared printer and sets it as default. It then pops up a message when done.

I didn’t realise you can use CSS to format the contents of the HTA, pretty obvious really but a nice surprise nonetheless. In the future I might put a pretty picture in the background and our logo somewhere but while time is short it’s functional and works a treat.

Also worthy of note is the method used to centre the box on the screen; most of the code snippets I saw were written for XP and used some clever methods to figure out the screen size that don’t really work in Windows 7. Luckily it’s a lot easier these days, just use this to resize and centre the window:

Sub Window_Onload
 window.resizeTo 400,250
 window.moveTo (screen.width - document.body.clientwidth)/2, (screen.height - document.body.clientheight)/2 
End Sub

The final step was to pin it to the Start Menu on the laptops only. The usual caveat applies that you can’t pin the file directly, your shortcut needs to go to c:\windows\system32\mshta.exe \\server\yourhta.exe then you can pin it using the scripts mentioned here

If you want to try it out for yourself grab the code from my SkyDrive folder


2 Responses to Tip of the day, have a play with HTAs

  1. Pingback: HTA based quick launcher for Adobe CS6 | gshaw0

  2. Pingback: Responsive captive portal login page for Aruba wireless | gshaw0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: