Managing Windows with VBscript and WMI

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 96%)
Other sellers (Paperback)
  • All (17) from $1.99   
  • New (4) from $21.95   
  • Used (13) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$21.95
Seller since 2009

Feedback rating:

(56)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
New New as pictured-CD-ROM IS SEALED, UNOPENED-clean, excellent condition-Ships from legendary independent online bookstore in Murrieta, California. Thousands of satisfied ... customers. We ship promptly and Worldwide. We work hard to earn your confidence. Orders are fully guaranteed, includes free Tracking and Delivery Confirmation and normally ships the same business day. We use bubble wrap lined heavy Kraft envelopes. Reliable customer service and no-hassle return policy. Why pay more? Read more Show Less

Ships from: Diamond Bar, CA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$24.95
Seller since 2009

Feedback rating:

(118)

Condition: New
PAPERBACK New 0321213343.

Ships from: Londonderry, NH

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$70.00
Seller since 2014

Feedback rating:

(113)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$70.00
Seller since 2014

Feedback rating:

(113)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by

Overview

"Finally, a step-by-step VBScripting book to make you look like a programmer without the time and sweat! Don't waste your time searching the Internet for examples--this book does it for you!"

--Greg A. Marino, Senior Systems Engineer/Consultant, Westtown Consulting Group, Inc.

Visual Basic Scripting (VBScript) and Windows Management Instrumentation (WMI) are vital tools for systems administrators grappling with the increasing complexity of Windows technologies. However, busy admins have been without a straightforward guide to scripting...until now.

Managing Windows® with VBScript and WMI explains how Windows administrators can effectively use VBScript to automate common administrative tasks and simplify complex ones. Detailed coverage of security concerns provides admins with the means for safely using VBScript in Windows environments. The book is organized around the problems you face daily, with reusable examples and coverage of Windows NT, Windows 2000, Windows XP, and Windows 2003.

This user-friendly reference demystifies scripting and then shows you how to produce new scripts from scratch. You will be producing useful scripts right away as you study the VBScript language and learn how to control nearly every aspect of the Windows operating system with WMI and the Active Directory Services Interface (ASDI). You will be able to build your own administrative Web pages and use advanced scripting technologies such as script encryption, scripting components, and script security. The book closes with still more ready-made example scripts accompanied by complete line-by-line explanations. The CD includes all the code from the book and trial versions of PrimalScript 3.0 and VbsEdit. A companion Web site provides updates and errata.

Inside you will find answers to such questions as:

  • How do you write effective logon scripts? Chapter 11
  • How do you write scripts that query and modify user and group information? Chapter 16
  • How can you query the IP addresses from multiple network adapters in multiple remote computers? Chapter 19
  • How can you design, write, run, test, and debug your own administrative Web pages? Chapter 24
  • How can you reuse code between various scripts? Chapter 25
Read More Show Less

Product Details

Meet the Author

Don Jones, MCSE, CTT+, is an independent consultant and founding partner of BrainCore.Net, the world leader in exam development and delivery technologies for the information technology industry. Don is the author of more than a dozen books and the creator and series editor of Sams Publishing's Delta Guide series, helping experienced administrators quickly get up to speed on Microsoft server technologies. Don is also a contributing editor and columnist for Microsoft® Certified Professional Magazine, the Microsoft technology columnist for CertCities.com, and a speaker at technology conferences.

Read More Show Less

Read an Excerpt

Microsoft introduced Visual Basic, Scripting Edition—commonly known as VBScript—in the mid-'90s, positioning it as a native replacement for Windows' aging command-line batch language, which was based on Microsoft's earliest operating system, MS-DOS. VBScript was intended to be easy to learn, powerful, and flexible. The language was included as an add-on to Windows 95 and Windows NT 4.0, was an optional installation component included in Windows 98, and was included in all editions of Windows Me, Windows 2000, Windows XP, and Windows Server 2003.

Software developers immediately seized upon VBScript for Web programming, particularly in Active Server Pages, Microsoft's rapid-development programming framework for the Web. However, Windows administrators—one of VBScript's initial target audiences—were left cold. VBScript seemed to be much more complicated than administrators' beloved MS-DOS-based batch language, and many didn't see the need to learn an entirely new batch language.

When Windows 2000 and Active Directory came along, however, administrators found that Windows administration had become a great deal more complex. Suddenly, administrators were searching for Resource Kit and other utilities that offered automated administration, especially for repetitive tasks. Active Directory enabled the use of VBScript for logon and logoff scripts, which seemed to promise more advanced use environment manipulation. At around the same time, Microsoft's naivete in releasing a powerful language like VBScript with absolutely no security controls resulted in a huge wave of high-impact VBScript-based viruses, forcing administrators to lock down their environments andremove VBScript as an option both for viruses and for administrative tools.

As a regular speaker at some of the country's top technical conferences that focus on Windows technologies, including MCP TechMentor, the past few years I've given half- and full-day sessions on VBScripting for Windows administrators, and the sessions have been incredibly popular. In these sessions, I try to provide just enough VBScript experience to make scripting possible, and then concentrate on accomplishing common administrative tasks with VBScript. I also cover the security concerns of VBScript and provide administrators with the means for safely using VBScript in their environments. This book is essentially a written form of those sessions, greatly expanded with more coverage of Windows Management Instrumentation and other advanced topics, and with more coverage of VBScript security issues and resolutions.

I'm not out to turn you into a programmer. In fact, one of the real successes of VBScript is that you don't need to be a programmer to use it. Most of what you'll be doing in this book involves using VBScript to tell Windows to do things for you; you'll be able to ignore much of VBScript's complexity, using it as a sort of electronic glue to combine various operating system functions.Who Should Read This Book?

The only assumption I have about you is that you already know how to administer some version of Microsoft Windows. You'll find that most of the material in this book is suitable for Windows NT, Windows 2000, and Windows Server 2003 environments, and it will continue to be useful through future versions of Windows. I do not assume that you have any background in programming, and I'm not going to give you a programming background.

You should have a desire to learn how to use what I call "the batch language of the twenty-first century" and a wish to move away from clumsier—and often more complex—batch files based on the MS-DOS batch language. Although some folks like to refer to batch files as scripts, I don't; and when you see how easy and flexible VBScript is, you'll understand why!How to Use This Book

You can read this book in order from the Introduction to the Appendix. However, if you already have some experience with VBScript, or if you just want to dive right into the more complete example scripts, you can skip around as much as you like. I've organized this book in the same way that I organize my live VBScripting sessions at conferences, so you may feel that it's some time before you really get into the meat of scripting. I assure you, though, that each example in this book—starting in Chapter 1—is focused on Windows administration. You'll get your feet wet right away!

I've also included In This Chapter elements at the start of each chapter and Coming Up elements at the end of each chapter. These are brief paragraphs that are intended to help set the stage and help you decide if you need to read a particular chapter or not. They'll also help you decide which chapter to read next based on your individual needs and interests. I hope that these elements—along with the cross-references I've included in each chapter—will help you zip straight to the scripting information that you need most.

To help you decide where to start, here's a brief overview of each chapter.Part I: Introduction to Windows Administrative Scripting

Part I serves as an introduction to the world of scripting and provides you with a methodology for approaching administrative tasks from a scripting standpoint. One of the most difficult parts about producing new scripts from scratch is the "Where do I start?" factor, and I'll provide you with a framework for figuring that out every time.Chapter 1: Scripting Concepts and Terminology

As I've already implied, administrative scripting isn't hard-core programming. Instead, it's using VBScript as a sort of electronic glue to secure various bits of the Windows operating system together. In this chapter, I'll introduce you to those various bits and set the stage with some basic terminology that you'll use throughout this book.Chapter 2: Running Scripts

Writing a script isn't much fun if you can't run the script, and so this chapter will focus on the technologies used to execute scripts. You might be surprised to learn how many different Microsoft products support scripting. In this chapter, I'll show you how far your scripting skills can really take you. I'll also introduce you to some scripting tools that can make writing and debugging scripts a bit easier.Chapter 3: The Components of a Script

In this chapter, I'll present a complete administrative script, and then break it down line-by-line to explain its various components. Although this chapter isn't necessary to learning administrative scripting, it will help you write scripts that are more reliable and easier to troubleshoot. Chapter 4: Designing a Script

As I've mentioned already, one of the toughest aspects about scripting can be figuring out where to start. In this chapter, I'll provide you with a framework that you can use as a starting point for every new scripting project. I'll also introduce you to some concepts that many scripting books ignore, such as planning for errors and creating a useful "resource kit" of script components that you can reuse throughout your scripting projects.Part II: VBScript Tutorial

Here's your official crash course to the VBScript language: just enough to make administration via script a possibility! The best part is that I won't use the trite "Hello, world" examples that books for software developers often start out with. Instead, I'll make every example useful to you as a Windows administrator. That means you'll be producing simple, useful scripts at the same time you're learning VBScript. What could be better?Chapter 5: Functions, Objects, Variables, and More

In this chapter, I'll show you the basic building blocks of any script and introduce you to some sample scripts that use each building block in a particular administrative task. This is really the meat of administrative scripting, and you'll be able to write useful scripts when you're finished with this chapter.Chapter 6: Input and Output

You can make your scripts more flexible by adding the ability to dynamically change computer, user, and domain names, along with other information. In this chapter, I'll show you how your script can collect information it needs to run and dynamically alter itself to take advantage of that information.Chapter 7: Manipulating Numbers

This chapter will explain how scripts can manipulate numbers, making it easier to create scripts that work with numeric data, such as user account data. I'll also introduce you to VBScript's numeric data handling and conversion commands, putting you on the path to some great scripting techniques. Chapter 8: Manipulating Strings

Strings—a fancy word for text data—are at the heart of most scripting tasks. In this chapter, I'll show you how VBScript deals with strings and how you can easily integrate them into your scripts.Chapter 9: Manipulating Other Types of Data

Aside from text and numbers, your scripts may need to deal with dates, times, bytes, and other forms of data to accomplish specific administrative tasks. In this chapter, I'll show you how VBScript handles these other data types and how you can use them in your own scripts.Chapter 10: Controlling the Flow of Execution

The best administrative scripts can respond to changing conditions with internal logic, called control-of-flow. In this chapter, I'll show you how your scripts can be made to evaluate various conditions and respond accordingly, perform repetitive tasks, and much more.Chapter 11: Built-in Scripting Objects

Much of VBScript's power comes from its capability to join various operating system objects, and in this chapter, I'll introduce you to your first set of those objects. You'll learn how to manipulate network information, map drives, and much more—pretty much everything you need to write effective logon scripts.Chapter 12: Working with the File System

A common use of scripting is to manipulate files and folders, and in this chapter, I'll introduce you to the VBScript FileSystemObject, which provides a complete object model for working with the file system. You'll learn to build a utility that scans IIS log files for error messages, a useful script for any environment!Chapter 13: Putting It All Together: Your First Script

This is where you'll put everything from Part II together. You'll be creating a script that rotates IIS log files, keeping the past 30 days' worth of files in a special archive folder. I'll guide you through the complete process of designing, writing, testing, and troubleshooting the script. In fact, I'll deliberately introduce some logic errors into the script so that you can see the debugging process in action.Part III: Windows Management Instrumentation and Active Directory Services Interface

With the glue of VBScript under your belt, I'll dive into the two most powerful technologies for administering Windows: Windows Management Instrumentation (WMI) and the Active Directory Services Interface (ADSI). These technologies provide administrative access to, and control over, nearly every aspect of the Windows operating system, from Windows NT to Windows Server 2003. Chapter 14: Working with ADSI Providers

Despite its name, ADSI isn't just for Active Directory. In this chapter, I'll show you how ADSI can be used to interface with NT, Active Directory, Novell NDS, Exchange Server, and other types of directory services. I'll provide some basic examples of the types of tasks you can perform with ADSI to get you started.Chapter 15: Manipulating Domains

With the ADSI basics out of the way, I'll focus on manipulating domain information in a script. You'll learn how to query domain information, modify domain policies like password length, and much more. Chapter 16: Manipulating Users and Groups

In this chapter, you'll learn how to write scripts that query and modify user and group information. This is one of the most common tasks you'll perform with VBScript, and I'll include plenty of useful examples. Chapter 17: Understanding WMI

WMI provides a hook into just about every portion of the Windows operating system, making it an incredibly useful tool for administrative scripts. In this chapter, I'll introduce you to WMI and show you a preview of what you can use it for in your environment. Chapter 18: Querying Basic WMI Information

Do you want to find out which users in your organization have a Pentium 4 computer? This chapter will show you how to write your own basic WMI queries, including those that involve remote machines. You'll also learn basic WMI manipulation, which lets you modify local and remote machine settings from within a script.Chapter 19: Querying Complex WMI Information

Some WMI queries are more complex, such as querying the IP addresses from multiple network adapters in multiple remote computers. This chapter provides clear examples of these more complex WMI tasks, helping you learn to write enterprise management scripts.Chapter 20: Putting It All Together: Your First WMI/ADSI Script

This is where it all comes together. I'll walk you through the process of designing, writing, testing, and debugging a complete WMI/ADSI script from scratch. You'll finish this chapter with a concrete example of the administrative capabilities of these technologies, and then you'll be ready to start writing your own scripts.Part IV: Creating Administrative Web Pages

One popular use of Web technologies inside corporate networks is to provide user self-service pages, such as a simple Web page where users can reset their own passwords, if necessary. In Part IV, I'll give you a crash course on IIS and Active Server Pages (ASP) and show you how to start building your own administrative Web pages.Chapter 21: Active Server Pages Crash Course

ASP is a great way to create effective administrative Web pages. I'm not going to try to make you a Web developer or an HTML expert; the Web pages you'll create in this chapter won't be pretty, but they'll be incredibly effective. Chapter 22: Adding Administrative Script to a Web Page

After you have a basic Web page ready, you can start adding script to it to make the Web page perform administrative tasks. I'll provide examples of real-world tasks that you can start using in your environment right away.Chapter 23: Web Page Security Overview

Web pages have special security concerns, which I'll focus on in this chapter. I'll explain how IIS 5.0 and 6.0 process Web pages, what you can and cannot easily accomplish from within a Web page, and how you can create a secure, stable environment for Web-based administrative scripts.Chapter 24: Putting It All Together: Your First Administrative Web Page

You're now ready to design, write, run, test, and debug your own administrative Web pages, and in this chapter, I'll step you through the entire progression. When you're finished, you'll not only have a ready-to-run administrative Web page to use, you'll also be ready to start creating your own Web pages from scratch. Again, they might not be pretty, but they'll be incredibly functional and useful.Part V: Advanced Scripting Techniques

As you become a more experienced scripter, you'll be ready to start saving time and be more secure, with advanced techniques like script encryption, scripting components, script security, and so forth. In this part of the book, I'll give you a comprehensive look at each of these technologies and show you how to put them into use in your own environment.Chapter 25: Modular Script Programming

If you find yourself cutting and pasting code—or worse, retyping it—this is the chapter for you. I'll introduce you to modular scripting concepts, which make it easier to reuse code between various scripts, saving you time and effort! By way of example, we'll start with a complex script that contains lots of useful code, and then break it down into easily reused modules. Chapter 26: Using Script Components

Windows Script Components are the easy way to create your own fully encapsulated chunks of script, each of which performs a useful task. Building on the examples in Chapter 25, I'll show you how to create and use script components to make administrative scripting faster and easier. You'll come away with a whole library of script components that you can start using immediately!Chapter 27: Encoded Scripts

Are you worried that others will peek into your scripts and steal your ideas? Scripting encryption helps protect your scripts from both Peeping Toms and potential misuse, so I'll show you how to set up, deploy, and use script encryption within your environment in this chapter.Chapter 28: Scripting Security

Some folks think Microsoft made a huge mistake when it included VBScript in the Windows operating system, but I disagree. Properly configured, scripting can be as safe as any other type of application. In this chapter, I'll explain scripting security concepts and introduce you to the tools that can make scripting a safe and valuable part of any computing environment.Part VI: Ready-to-Run Examples

I figured a great way to wrap up the book would be a whole section on ready-made example scripts that you can start using in your own environment. Additionally, these scripts—like every other script in this book—will have complete, line-by-line explanations, making them a perfect reference guide as you start to create your own scripts from scratch.Chapter 29: Logon and Logoff Scripts

I'll use this chapter to present more complex logon and logoff scripts and to give you some ideas for how scripting can make these important scripts more effective. Of course, the line-by-line explanations will make each script a useful reference for customizing your own scripts. Chapter 30: Windows and Domain Administration Scripts

Automating domain administration is probably one of the big reasons you started looking at scripting in the first place, so I'll use this chapter to present a number of examples of tasks that scripts can perform. The detailed explanations with each script will help you rip them apart and customize them for your own use.Chapter 31: Network Administration Scripts

Network administration is ideally suited for scripting, and in this chapter, I'll provide a handful of examples that will show you what's possible. The line-by-line explanations will make it easy to put these into use in your own environment.Chapter 32: WMI and ADSI Scripts

These can be the toughest scripts to write due to the complexity and flexibility of WMI and ADSI. In this chapter, I'll provide you with several ready-to-use scripts for common tasks like querying WMI, creating users and groups, and more. These scripts can be easily modified and incorporated into your own scripts, saving you scripting time!Part VII: AppendixAppendix: Administrator's Quick Script Reference

One of the toughest parts about VBScript is that it contains so much functionality. It's usually pretty easy to figure out what you want a script to do; the tough part is often figuring out how to make VBScript do it! In this appendix, I'll provide you with an alphabetical list of common tasks and give the VBScript commands that perform each task. You can use this reference along with the VBScript documentation to make designing and writing scripts much easier.Preparing to Use This Book

Before you dive in, you should make sure that your computers are ready for VBScript. Fortunately, any computer with Windows 2000 or later is ready to go out of the box, and I'll assume that you're doing your development work on either a Windows 2000-, Windows XP-, or Windows Server 2003-based computer. Typographical Elements

Books on programming can benefit a great deal from easy-to-understand typestyles and elements like the ones I'll explain here. These typestyles and elements are designed to make the text easier to follow and to call your attention to special concerns.

Boldfaced type will be used to set off material that should be typed into the computer; boldfaced also will be used to signify onscreen menu and/or dialog box selections. For example, "select Run from the Start menu, type wbemtest, and click OK" sets off the menu selection, what you need to type onscreen, and what should be clicked from the dialog box. Blocks of code and code lines that appear within the text will appear in a monospaced font, as in, "to change the contents of a variable, you can use something like

Var1 = Trim(Var1)."

TIP Tips will provide shortcuts and other "insider advice" about scripting that you'll find valuable.

NOTE Notes will provide cautions and other clarifications that will help you avoid problems or further clarify complex concepts.

I'll also direct you to material that more thoroughly explains particular concepts, VBScript commands, and so forth. Although I'm not a big fan of flipping back and forth through a book, these cross-references will allow you to remain focused within each chapter and will guide you to more detailed explanations, when appropriate.

Finally, there are times when it is necessary to present an extended explanation of something that isn't critical to the task at hand. In those cases, I'll use a sidebar. A sidebar is a cue that the information is useful, but it's not really key to the main text; you're welcome to skip the sidebar and come back to it later if you like.

Sidebars
Sidebars make it easier to cover slightly off-topic information without distracting you from the main text.>>Sample Scripts

Obviously, a book on scripting is going to have many code listings. To make these as useful as possible, I introduce each example script with a special head style, and present it in a listing by itself with no comments.

Listing P.1 A Sample Script. Accepts a name, and then redisplays that name.

'Get the user's name
sName = InputBox("What is your name?")

'Display the user's name
MsgBox "Your name is " & sName

After I present each script, I'll briefly review any changes you might need to make to get the script running in your environment, such as changing computer or domain names. You'll find each complete script included on the CD that accompanies this book. I've created a separate folder for each chapter and named the script files by their listing number for easy reference.>>Sample Scripts—Explained

For each script in this book, I'll include a line-by-line explanation of the script, so that you understand exactly what's going on. For example:

First, the sample script will display a dialog box where the user can type his name. By default, this dialog box includes an OK and Cancel button; I'm not providing any way to detect the Cancel button in this script, so I'm assuming the user will type something and click OK.

'Get the user's name
sName = InputBox("What is your name?")

Finally, the script uses the MsgBox statement to redisplay the user's name. Notice the use of the ampersand operator (&) to tack on the contents of the variable sName, which stores whatever the user typed into the input box.

'Display the user's name
MsgBox "Your name is " & sName

Walk-throughs like this one will help you become more familiar with VBScript, what each command does, and exactly how each example script works.

Read More Show Less

Table of Contents

Preface
Acknowledgments
About the Author
Pt. I Introduction to Windows Administrative Scripting 1
Ch. 1 Scripting Concepts and Terminology 3
Ch. 2 Running Scripts 11
Ch. 3 The Components of a Script 29
Ch. 4 Designing a Script 47
Pt. II VBScript Tutorial 69
Ch. 5 Functions, Objects, Variables, and More 71
Ch. 6 Input and Output 99
Ch. 7 Manipulating Numbers 117
Ch. 8 Manipulating Strings 133
Ch. 9 Manipulating Other Types of Data 147
Ch. 10 Controlling the Flow of Execution 157
Ch. 11 Built-in Scripting Objects 175
Ch. 12 Working with the File System 193
Ch. 13 Putting It All Together: Your First Script 223
Pt. III Windows Management Instrumentation and Active Directory Services Interface 253
Ch. 14 Working with ADSI Providers 255
Ch. 15 Manipulating Domains 265
Ch. 16 Manipulating Users and Groups 281
Ch. 17 Understanding WMI 293
Ch. 18 Querying Basic WMI Information 311
Ch. 19 Querying Complex WMI Information 331
Ch. 20 Putting It All Together: Your First WMI/ADSI Script 351
Pt. IV Creating Administrative Web Pages 375
Ch. 21 Active Server Pages Crash Course 377
Ch. 22 Adding Administrative Script to a Web Page 393
Ch. 23 Web Page Security Overview 419
Ch. 24 Putting It All Together: Your First Administrative Web Pages 433
Pt. V Advanced Scripting Techniques 461
Ch. 25 Modular Script Programming 463
Ch. 26 Using Script Components 475
Ch. 27 Encoded Scripts 481
Ch. 28 Scripting Security 487
Pt. VI Ready-to-Run Examples 497
Ch. 29 Logon and Logoff Scripts 499
Ch. 30 Windows and Domain Administration Scripts 517
Ch. 31 Network Administration Scripts 541
Ch. 32 WMI and ADSI Scripts 567
Pt. VII Appendix 577
App Administrator's Quick Script Reference 579
Index 591
Read More Show Less

Preface

Microsoft introduced Visual Basic, Scripting Edition--commonly known as VBScript--in the mid-'90s, positioning it as a native replacement for Windows' aging command-line batch language, which was based on Microsoft's earliest operating system, MS-DOS. VBScript was intended to be easy to learn, powerful, and flexible. The language was included as an add-on to Windows 95 and Windows NT 4.0, was an optional installation component included in Windows 98, and was included in all editions of Windows Me, Windows 2000, Windows XP, and Windows Server 2003.

Software developers immediately seized upon VBScript for Web programming, particularly in Active Server Pages, Microsoft's rapid-development programming framework for the Web. However, Windows administrators--one of VBScript's initial target audiences--were left cold. VBScript seemed to be much more complicated than administrators' beloved MS-DOS-based batch language, and many didn't see the need to learn an entirely new batch language.

When Windows 2000 and Active Directory came along, however, administrators found that Windows administration had become a great deal more complex. Suddenly, administrators were searching for Resource Kit and other utilities that offered automated administration, especially for repetitive tasks. Active Directory enabled the use of VBScript for logon and logoff scripts, which seemed to promise more advanced use environment manipulation. At around the same time, Microsoft's naivete in releasing a powerful language like VBScript with absolutely no security controls resulted in a huge wave of high-impact VBScript-based viruses, forcing administrators to lock down their environments and remove VBScript as an option both for viruses and for administrative tools.

As a regular speaker at some of the country's top technical conferences that focus on Windows technologies, including MCP TechMentor, the past few years I've given half- and full-day sessions on VBScripting for Windows administrators, and the sessions have been incredibly popular. In these sessions, I try to provide just enough VBScript experience to make scripting possible, and then concentrate on accomplishing common administrative tasks with VBScript. I also cover the security concerns of VBScript and provide administrators with the means for safely using VBScript in their environments. This book is essentially a written form of those sessions, greatly expanded with more coverage of Windows Management Instrumentation and other advanced topics, and with more coverage of VBScript security issues and resolutions.

I'm not out to turn you into a programmer. In fact, one of the real successes of VBScript is that you don't need to be a programmer to use it. Most of what you'll be doing in this book involves using VBScript to tell Windows to do things for you; you'll be able to ignore much of VBScript's complexity, using it as a sort of electronic glue to combine various operating system functions.

Who Should Read This Book?

The only assumption I have about you is that you already know how to administer some version of Microsoft Windows. You'll find that most of the material in this book is suitable for Windows NT, Windows 2000, and Windows Server 2003 environments, and it will continue to be useful through future versions of Windows. I do not assume that you have any background in programming, and I'm not going to give you a programming background.

You should have a desire to learn how to use what I call "the batch language of the twenty-first century" and a wish to move away from clumsier--and often more complex--batch files based on the MS-DOS batch language. Although some folks like to refer to batch files as scripts, I don't; and when you see how easy and flexible VBScript is, you'll understand why!

How to Use This Book

You can read this book in order from the Introduction to the Appendix. However, if you already have some experience with VBScript, or if you just want to dive right into the more complete example scripts, you can skip around as much as you like. I've organized this book in the same way that I organize my live VBScripting sessions at conferences, so you may feel that it's some time before you really get into the meat of scripting. I assure you, though, that each example in this book--starting in Chapter 1--is focused on Windows administration. You'll get your feet wet right away!

I've also included In This Chapter elements at the start of each chapter and Coming Up elements at the end of each chapter. These are brief paragraphs that are intended to help set the stage and help you decide if you need to read a particular chapter or not. They'll also help you decide which chapter to read next based on your individual needs and interests. I hope that these elements--along with the cross-references I've included in each chapter--will help you zip straight to the scripting information that you need most.

To help you decide where to start, here's a brief overview of each chapter.

Part I: Introduction to Windows Administrative Scripting

Part I serves as an introduction to the world of scripting and provides you with a methodology for approaching administrative tasks from a scripting standpoint. One of the most difficult parts about producing new scripts from scratch is the "Where do I start?" factor, and I'll provide you with a framework for figuring that out every time.

Chapter 1: Scripting Concepts and Terminology

As I've already implied, administrative scripting isn't hard-core programming. Instead, it's using VBScript as a sort of electronic glue to secure various bits of the Windows operating system together. In this chapter, I'll introduce you to those various bits and set the stage with some basic terminology that you'll use throughout this book.

Chapter 2: Running Scripts

Writing a script isn't much fun if you can't run the script, and so this chapter will focus on the technologies used to execute scripts. You might be surprised to learn how many different Microsoft products support scripting. In this chapter, I'll show you how far your scripting skills can really take you. I'll also introduce you to some scripting tools that can make writing and debugging scripts a bit easier.

Chapter 3: The Components of a Script

In this chapter, I'll present a complete administrative script, and then break it down line-by-line to explain its various components. Although this chapter isn't necessary to learning administrative scripting, it will help you write scripts that are more reliable and easier to troubleshoot.

Chapter 4: Designing a Script

As I've mentioned already, one of the toughest aspects about scripting can be figuring out where to start. In this chapter, I'll provide you with a framework that you can use as a starting point for every new scripting project. I'll also introduce you to some concepts that many scripting books ignore, such as planning for errors and creating a useful "resource kit" of script components that you can reuse throughout your scripting projects.

Part II: VBScript Tutorial

Here's your official crash course to the VBScript language: just enough to make administration via script a possibility! The best part is that I won't use the trite "Hello, world" examples that books for software developers often start out with. Instead, I'll make every example useful to you as a Windows administrator. That means you'll be producing simple, useful scripts at the same time you're learning VBScript. What could be better?

Chapter 5: Functions, Objects, Variables, and More

In this chapter, I'll show you the basic building blocks of any script and introduce you to some sample scripts that use each building block in a particular administrative task. This is really the meat of administrative scripting, and you'll be able to write useful scripts when you're finished with this chapter.

Chapter 6: Input and Output

You can make your scripts more flexible by adding the ability to dynamically change computer, user, and domain names, along with other information. In this chapter, I'll show you how your script can collect information it needs to run and dynamically alter itself to take advantage of that information.

Chapter 7: Manipulating Numbers

This chapter will explain how scripts can manipulate numbers, making it easier to create scripts that work with numeric data, such as user account data. I'll also introduce you to VBScript's numeric data handling and conversion commands, putting you on the path to some great scripting techniques.

Chapter 8: Manipulating Strings

Strings--a fancy word for text data--are at the heart of most scripting tasks. In this chapter, I'll show you how VBScript deals with strings and how you can easily integrate them into your scripts.

Chapter 9: Manipulating Other Types of Data

Aside from text and numbers, your scripts may need to deal with dates, times, bytes, and other forms of data to accomplish specific administrative tasks. In this chapter, I'll show you how VBScript handles these other data types and how you can use them in your own scripts.

Chapter 10: Controlling the Flow of Execution

The best administrative scripts can respond to changing conditions with internal logic, called control-of-flow. In this chapter, I'll show you how your scripts can be made to evaluate various conditions and respond accordingly, perform repetitive tasks, and much more.

Chapter 11: Built-in Scripting Objects

Much of VBScript's power comes from its capability to join various operating system objects, and in this chapter, I'll introduce you to your first set of those objects. You'll learn how to manipulate network information, map drives, and much more--pretty much everything you need to write effective logon scripts.

Chapter 12: Working with the File System

A common use of scripting is to manipulate files and folders, and in this chapter, I'll introduce you to the VBScript FileSystemObject, which provides a complete object model for working with the file system. You'll learn to build a utility that scans IIS log files for error messages, a useful script for any environment!

Chapter 13: Putting It All Together: Your First Script

This is where you'll put everything from Part II together. You'll be creating a script that rotates IIS log files, keeping the past 30 days' worth of files in a special archive folder. I'll guide you through the complete process of designing, writing, testing, and troubleshooting the script. In fact, I'll deliberately introduce some logic errors into the script so that you can see the debugging process in action.

Part III: Windows Management Instrumentation and Active Directory Services Interface

With the glue of VBScript under your belt, I'll dive into the two most powerful technologies for administering Windows: Windows Management Instrumentation (WMI) and the Active Directory Services Interface (ADSI). These technologies provide administrative access to, and control over, nearly every aspect of the Windows operating system, from Windows NT to Windows Server 2003.

Chapter 14: Working with ADSI Providers

Despite its name, ADSI isn't just for Active Directory. In this chapter, I'll show you how ADSI can be used to interface with NT, Active Directory, Novell NDS, Exchange Server, and other types of directory services. I'll provide some basic examples of the types of tasks you can perform with ADSI to get you started.

Chapter 15: Manipulating Domains

With the ADSI basics out of the way, I'll focus on manipulating domain information in a script. You'll learn how to query domain information, modify domain policies like password length, and much more.

Chapter 16: Manipulating Users and Groups

In this chapter, you'll learn how to write scripts that query and modify user and group information. This is one of the most common tasks you'll perform with VBScript, and I'll include plenty of useful examples.

Chapter 17: Understanding WMI

WMI provides a hook into just about every portion of the Windows operating system, making it an incredibly useful tool for administrative scripts. In this chapter, I'll introduce you to WMI and show you a preview of what you can use it for in your environment.

Chapter 18: Querying Basic WMI Information

Do you want to find out which users in your organization have a Pentium 4 computer? This chapter will show you how to write your own basic WMI queries, including those that involve remote machines. You'll also learn basic WMI manipulation, which lets you modify local and remote machine settings from within a script.

Chapter 19: Querying Complex WMI Information

Some WMI queries are more complex, such as querying the IP addresses from multiple network adapters in multiple remote computers. This chapter provides clear examples of these more complex WMI tasks, helping you learn to write enterprise management scripts.

Chapter 20: Putting It All Together: Your First WMI/ADSI Script

This is where it all comes together. I'll walk you through the process of designing, writing, testing, and debugging a complete WMI/ADSI script from scratch. You'll finish this chapter with a concrete example of the administrative capabilities of these technologies, and then you'll be ready to start writing your own scripts.

Part IV: Creating Administrative Web Pages

One popular use of Web technologies inside corporate networks is to provide user self-service pages, such as a simple Web page where users can reset their own passwords, if necessary. In Part IV, I'll give you a crash course on IIS and Active Server Pages (ASP) and show you how to start building your own administrative Web pages.

Chapter 21: Active Server Pages Crash Course

ASP is a great way to create effective administrative Web pages. I'm not going to try to make you a Web developer or an HTML expert; the Web pages you'll create in this chapter won't be pretty, but they'll be incredibly effective.

Chapter 22: Adding Administrative Script to a Web Page

After you have a basic Web page ready, you can start adding script to it to make the Web page perform administrative tasks. I'll provide examples of real-world tasks that you can start using in your environment right away.

Chapter 23: Web Page Security Overview

Web pages have special security concerns, which I'll focus on in this chapter. I'll explain how IIS 5.0 and 6.0 process Web pages, what you can and cannot easily accomplish from within a Web page, and how you can create a secure, stable environment for Web-based administrative scripts.

Chapter 24: Putting It All Together: Your First Administrative Web Page

You're now ready to design, write, run, test, and debug your own administrative Web pages, and in this chapter, I'll step you through the entire progression. When you're finished, you'll not only have a ready-to-run administrative Web page to use, you'll also be ready to start creating your own Web pages from scratch. Again, they might not be pretty, but they'll be incredibly functional and useful.

Part V: Advanced Scripting Techniques

As you become a more experienced scripter, you'll be ready to start saving time and be more secure, with advanced techniques like script encryption, scripting components, script security, and so forth. In this part of the book, I'll give you a comprehensive look at each of these technologies and show you how to put them into use in your own environment.

Chapter 25: Modular Script Programming

If you find yourself cutting and pasting code--or worse, retyping it--this is the chapter for you. I'll introduce you to modular scripting concepts, which make it easier to reuse code between various scripts, saving you time and effort! By way of example, we'll start with a complex script that contains lots of useful code, and then break it down into easily reused modules.

Chapter 26: Using Script Components

Windows Script Components are the easy way to create your own fully encapsulated chunks of script, each of which performs a useful task. Building on the examples in Chapter 25, I'll show you how to create and use script components to make administrative scripting faster and easier. You'll come away with a whole library of script components that you can start using immediately!

Chapter 27: Encoded Scripts

Are you worried that others will peek into your scripts and steal your ideas? Scripting encryption helps protect your scripts from both Peeping Toms and potential misuse, so I'll show you how to set up, deploy, and use script encryption within your environment in this chapter.

Chapter 28: Scripting Security

Some folks think Microsoft made a huge mistake when it included VBScript in the Windows operating system, but I disagree. Properly configured, scripting can be as safe as any other type of application. In this chapter, I'll explain scripting security concepts and introduce you to the tools that can make scripting a safe and valuable part of any computing environment.

Part VI: Ready-to-Run Examples

I figured a great way to wrap up the book would be a whole section on ready-made example scripts that you can start using in your own environment. Additionally, these scripts--like every other script in this book--will have complete, line-by-line explanations, making them a perfect reference guide as you start to create your own scripts from scratch.

Chapter 29: Logon and Logoff Scripts

I'll use this chapter to present more complex logon and logoff scripts and to give you some ideas for how scripting can make these important scripts more effective. Of course, the line-by-line explanations will make each script a useful reference for customizing your own scripts.

Chapter 30: Windows and Domain Administration Scripts

Automating domain administration is probably one of the big reasons you started looking at scripting in the first place, so I'll use this chapter to present a number of examples of tasks that scripts can perform. The detailed explanations with each script will help you rip them apart and customize them for your own use.

Chapter 31: Network Administration Scripts

Network administration is ideally suited for scripting, and in this chapter, I'll provide a handful of examples that will show you what's possible. The line-by-line explanations will make it easy to put these into use in your own environment.

Chapter 32: WMI and ADSI Scripts

These can be the toughest scripts to write due to the complexity and flexibility of WMI and ADSI. In this chapter, I'll provide you with several ready-to-use scripts for common tasks like querying WMI, creating users and groups, and more. These scripts can be easily modified and incorporated into your own scripts, saving you scripting time!

Part VII: Appendix

Appendix: Administrator's Quick Script Reference

One of the toughest parts about VBScript is that it contains so much functionality. It's usually pretty easy to figure out what you want a script to do; the tough part is often figuring out how to make VBScript do it! In this appendix, I'll provide you with an alphabetical list of common tasks and give the VBScript commands that perform each task. You can use this reference along with the VBScript documentation to make designing and writing scripts much easier.

Preparing to Use This Book

Before you dive in, you should make sure that your computers are ready for VBScript. Fortunately, any computer with Windows 2000 or later is ready to go out of the box, and I'll assume that you're doing your development work on either a Windows 2000-, Windows XP-, or Windows Server 2003-based computer.

Typographical Elements

Books on programming can benefit a great deal from easy-to-understand typestyles and elements like the ones I'll explain here. These typestyles and elements are designed to make the text easier to follow and to call your attention to special concerns.

Boldfaced type will be used to set off material that should be typed into the computer; boldfaced also will be used to signify onscreen menu and/or dialog box selections. For example, "select Run from the Start menu, type wbemtest, and click OK" sets off the menu selection, what you need to type onscreen, and what should be clicked from the dialog box. Blocks of code and code lines that appear within the text will appear in a monospaced font, as in, "to change the contents of a variable, you can use something like Var1 = Trim(Var1)."

TIP Tips will provide shortcuts and other "insider advice" about scripting that you'll find valuable.

NOTE Notes will provide cautions and other clarifications that will help you avoid problems or further clarify complex concepts.

I'll also direct you to material that more thoroughly explains particular concepts, VBScript commands, and so forth. Although I'm not a big fan of flipping back and forth through a book, these cross-references will allow you to remain focused within each chapter and will guide you to more detailed explanations, when appropriate.

Finally, there are times when it is necessary to present an extended explanation of something that isn't critical to the task at hand. In those cases, I'll use a sidebar. A sidebar is a cue that the information is useful, but it's not really key to the main text; you're welcome to skip the sidebar and come back to it later if you like.

Sidebars
Sidebars make it easier to cover slightly off-topic information without distracting you from the main text.

Sample Scripts

Obviously, a book on scripting is going to have many code listings. To make these as useful as possible, I introduce each example script with a special head style, and present it in a listing by itself with no comments.

Listing P.1 A Sample Script. Accepts a name, and then redisplays that name.

'Get the user's name sName = InputBox("What is your name?")

'Display the user's name MsgBox "Your name is " & sName

After I present each script, I'll briefly review any changes you might need to make to get the script running in your environment, such as changing computer or domain names. You'll find each complete script included on the CD that accompanies this book. I've created a separate folder for each chapter and named the script files by their listing number for easy reference.

Sample Scripts--Explained

For each script in this book, I'll include a line-by-line explanation of the script, so that you understand exactly what's going on. For example:

First, the sample script will display a dialog box where the user can type his name. By default, this dialog box includes an OK and Cancel button; I'm not providing any way to detect the Cancel button in this script, so I'm assuming the user will type something and click OK.

'Get the user's name sName = InputBox("What is your name?")

Finally, the script uses the MsgBox statement to redisplay the user's name. Notice the use of the ampersand operator (&) to tack on the contents of the variable sName, which stores whatever the user typed into the input box.

'Display the user's name MsgBox "Your name is " & sName

Walk-throughs like this one will help you become more familiar with VBScript, what each command does, and exactly how each example script works.

0321213343P02272004

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)