Instant Log-On Scripts
Generating VBScipt log-on scripts -- without all the the VBS.
- By Jeffery Hicks
Even though Group Policy has taken us a long way since the days of NT4 and
Windows 2000, and even though the combination of Vista and Longhorn promises
much more, many shops still have to use log-on scripts.
I know some people who use log-on scripts extensively as an active part of
their management strategy. However, most of you only need log-on scripts to
map a few drives and printers and maybe provide some user information.
Most log-on scripts are written in VBScript. What if you don't know your WSH
from your VBS, though? Wouldn't it be nice to generate VBScript log-on scripts
without having to know a lot of scripting -- or any scripting at all, for that
matter? I thought it might, so I developed the Log-On Script Generator.
This HTML application (HTA) is designed to rapidly develop a log-on script
based on your input. You just have to make a few choices from drop down lists
and check boxes. The only configuration you have to do is to edit two text files
and put them in the same directory as the HTA.
One file is a list of all the file shares you might want to assign in UNC format.
You can even include %username% in the UNC and
it will be translated to the user's username. The other file is a list of all
printer shares, also in UNC format.
When you start the Log-On Script Generator, it will search your domain and
populate the drop downs with group names. If you want to map drive P to \\File01\public,
for example, select the drive and group from the drop downs and click the "Add
Drive" button. Repeat this for as many drive mappings as you need. If you
want the drive mapping to apply to all users, don't select a group.
You can follow the same process to map printer assignments. If you need some
legacy printing support such as mapping a printer to LPT1, you can also do that.
That's probably all you'd need for a basic log-on script. I've also added several
options to display a welcome message to the user, display their password age
and display an error message if there's a problem mapping drives or printers,
as well as displaying a summary of mapped resources. If you decide to display
messages to the user, you can control how long the message will be displayed.
The default is 10 seconds, after which the message box will close by itself.
Need to run a third-party tool or some other code? No problem. There's a section
where you can add additional commands to your script. You can even add some
comments or documentation so you know who created the script and when. Once
you've made your selections, click the "Create Script" button. You'll
see your complete VBScript, and you didn't have to write a single line of code.
If you don't like what you have, click "Reset" and start over.
You can make some changes within the Log-On Script Generator after you've created
the script, but this utility really isn't a script editor, per se. What you
can do is click the "Save File" button to save a copy of the script.
You'll see an option to load your finished script into a scripting environment
like PrimalScript (if you have it) for further work. Otherwise, you can open
the file in Notepad.
If you have another scripting editor, all you need to do is open the saved
file and edit it from there. The Log-On Script Generator is offered as a free
scripting tool from Sapien Technologies Inc., so it has the edit link. But there's
nothing preventing you from modifying the HTA to add a link to your script editor
Don't forget to test your log-on script before you deploy it. If editing it
is too much work, fire up the Log-On Script Generator and start again. Within
minutes you'll have another complete script ready to go.
Jeffery Hicks is a Microsoft MVP in Windows PowerShell, Microsoft Certified Trainer and an IT veteran with over 20 years of experience, much of it spent as an IT consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He works today as an independent author, trainer and consultant. Jeff writes the popular Prof. PowerShell column for MPCMag.com and is a regular contributor to the Petri IT Knowledgebase and 4SysOps. If he isn't writing, then he's most likely recording training videos for companies like TrainSignal or hanging out in the forums at PowerShell.org.
Jeff's latest books are Learn PowerShell 3 in a Month of Lunches, Learn PowerShell Toolmaking in a Month of Lunches and PowerShell in Depth: An Administrators Guide.
You can keep up with Jeff at his blog http://jdhitsolutions.com/blog, on Twitter at twitter.com/jeffhicks and on Google Plus (http:/gplus.to/JeffHicks)