Chapter 1: The Essentials of Scripting


This chapter introduces the basic techniques of scripting and the three major scripting tools used throughout this book: Shell Scripting, KiXtart, and Windows Script Host. By the end of this chapter you'll learn the basics of each approach, the limitations, and when to use them. Because this book covers a lot of ground, I included this scripting introduction to help you get up to speed with the tools and basic techniques that I'll be using throughout this book. It also shows you how to write scripts to perform a wide range of Windows administration tasks .

The Essence of Scripting

Scripts are the simplest form of programming, and anyone who uses a computer can create them with a little practice. I've stated this before, but I cannot emphasize this enough. Scripting is a fast, simple way to instruct a computer to perform a specific set of instructions. These instructions can range from simple tasks like "delete temporary files from a computer" to more complex tasks like "install this application on every machine on the network." A script is merely a text file that contains a set of commands for performing a specific operation. The best part about scripting is that you can do a lot with a little bit of programming knowledge. The scripting tools and languages are easy to learn and the skills you develop with one scripting tool can easily be adapted to another tool. The scripting tools I've selected for this book are all especially designed to be easy to use, yet provide many powerful features so that you can perform a wide range of tasks.

Scripts vs. Programs

Computers only understand binary operations (on or off, 1 or 0). When a script runs, the scripting engine reads each line of code and translates it into machine language on the fly. This is why scripts are also called interpreted programs . High level languages such as Visual Basic .NET and C# must be translated into machine language by a compiler before execution. Because scripts compile at runtime, they tend to run slower than compiled programs. The good news, however, is that the types of tasks you'll typically perform with scripts aren't so speed critical and thus the simplicity of using a scripting tool far outweighs the complexity of using a programming language.

Limitations of Scripting

While high level languages contain an extensive library or set of functions, scripting languages only contain subsets of their counterparts or comparables. Scripting languages do not usually supply graphical interface elements, such as forms, dropdown lists, checkboxes, and so on. Finally, scripting languages do not typically provide advanced programming features such as object orientation, early binding, and threading.

When to Use Scripts

Scripting languages are designed to be lightweight and easier to work with than their compiled counterparts. In some cases, scripts can even perform tasks more quickly than can be performed with compiled programs simply because scripts do not contain a lot of extra baggage. Scripting is best used when you need quick solutions without a full blown interface or intensive processing. If you find a script is using a lot of system resources, taking a long time to complete, or is simply unmanageable due to its size or complexity, you should consider using a compiled program.




Windows Admin Scripting Little Black Book
Windows Admin Scripting Little Black Book (Little Black Books (Paraglyph Press))
ISBN: 1933097108
EAN: 2147483647
Year: 2004
Pages: 89

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net