If you want some ideas, take a look at the PDF manual for the Universal Login Script on my web site.
There are lots of error checks, logging and debug levels. All data is maintained in an external config file.
If you're doing this for clients, you might want to consider using our script (it's free, and we do offer commercial support). We have it implemented at most of our client sites, and can put up a simple script in a few minutes, and a complex one in an hour or two, without any coding at all.
One item - installing software via login script is generally not a good idea. It depends on users having admin rights, which itself isn't a good idea. We do employ login detection procedures that identify when an install is needed, and it schedules an immediate push install with proper admin rights as a separate process.
Glenn
_________________________
Actually I
am a Rocket Scientist!