Chapter 4. Designing a Script
IN THIS CHAPTER
Believe it or not, the toughest part about scripting isn't the language or programming objects or anything technology related. It's in how you design your scripts and get them to do what you want. I'll share tips and techniques that'll make scripting easier and more approachable.
Suppose you want to do a tune-up on your car, and you don't want to hire a mechanic to do the job for you. It's easy enough to run down to the hardware store and acquire the necessary tools, and you can even buy some books that explain how to use those tools. If you're like me, though, none of that will help you get the tune-up done. Where do you start? What should it look like? Which tools do you use, and when?
I've found that's how many administrators feel about scripting. Sure, the VBScript documentation is available, and there are plenty of examples on the Web. But where do you start when it comes time to write your own scripts? Much of this book will be focused on the tools, like VBScript and programming objects, that you'll need to do the job. In this chapter, I want to share some of the tips and techniques that I use to actually get started in designing a new script.
It'll be easier to see how my design process works with a meaningful example. Because login scripts are a popular administrative use of VBScript, I'll use a login script as an example. I want to write a login script that maps three network drives based on the users' group membership, and then maps a printer based on the user's DHCP-assigned IP address. That way, I can assign a printer that's local to wherever the user logged on. I also want to display a welcome message, and I want the script to run on Windows NT Workstation 4.0 (Service Pack 6a or later), Windows XP Professional (Service Pack 1 or later), and Windows 2000 Professional (Service Pack 3 or later).
|