VBScript Programmer's Reference, Third Edition
Buy Rights Online Buy Rights

Rights Contact Login For More Details

More About This Title VBScript Programmer's Reference, Third Edition

English

Completely updated for Windows Vista and Windows Server 2003 R2, this book is packed with practical examples for today's programmer, Web developer, or system administratorCombines a comprehensive overview of the VBScript technology and associated technologies with sample code at every stage from beginner to advanced userDiscusses the general syntax, functions, keywords, style, error handling, and similar language-specific topics and then moves into an expanded reference section covering the object models in detailPresents advanced coverage on Active Directory Service Interfaces (ADSI), PowerShell, security scripting, remote scripting, database scripting, and more

English

Adrian Kingsley-Hughes has made his living as a technology writer for over a decade, with many books and articles to his name. He can also be found teaching classes on the Web, where he has successfully taught technology skills to thousands of learners, with his own special brand of knowledge, experience, wit, and poor spelling. He is also editor of the ZDNet blog Hardware 2.0 ( http://blogs.zdnet.com/hardware ).

Kathie Kingsley-Hughes has worked in IT training for many years. In addition to writing, she now works as a courseware developer and e-trainer, specializing in Internet technologies. She also runs a web development company in the United Kingdom.

Daniel Read is a software developer living and working in Atlanta, GA, USA. He currently works for Connecture Inc., an Atlanta-based software consulting firm specializing in the insurance industry. Daniel also publishes and writes essays for developers at DeveloperDotStar.com , a web-based magazine for software professionals.

English

Acknowledgments xi

Introduction xxv

Chapter 1: A Quick Introduction to Programming 1

Variables and Data Types 2

Flow Control 9

Operators and Operator Precedence 18

Organizing and Reusing Code 19

Top-Down versus Event-Driven 23

Coding Guidelines 25

Summary 29

Chapter 2: What VBScript Is — and Isn’t! 31

Windows Script 31

Version Information 32

VBScript Is a Subset of VB 32

VBScript Is a Scripting Language 33

VBScript Is Interpreted at Runtime 33

Advantages of Using VBScript 36

Is VBScript Right for You? 37

How VBScript Fits in with the Visual Basic Family 38

What Can You Do with VBScript? 40

Tool of the Trade — Tools for VBScript 43

Summary 44

Chapter 3: Data Types 45

Scripting Languages as Loosely Typed 46

Why Data Types Are Important 47

The Variant: VBScript’s Only Data Type 49

Arrays as Complex Data Types 72

Summary 81

Chapter 4: Variables and Procedures 83

Option Explicit 83

Naming Variables 85

Procedures and Functions 86

Variable Scope, Declaration, and Lifetime 95

Design Strategies for Scripts and Procedures 99

ByRef and ByVal 101

Literals and Named Constants 104

Summary 108

Chapter 5: Control of Flow 109

Branching Constructs 109

Loop Constructs 114

Summary 128

Chapter 6: Error Handling and Debugging 129

Types of Errors 130

Error Visibility and Context 137

Handling Errors 139

Generating Custom Errors 152

Debugging 157

Summary 181

Chapter 7: The Scripting Runtime Objects 183

What Are Runtime Objects? 183

Object Basics 184

The Dictionary Object 190

The FileSystemObject Library 196

Summary 207

Chapter 8: Classes in VBScript (Writing Your Own COM Objects) 209

Objects, Classes, and Components 209

The Class Statement 211

Defining Properties 212

Defining Methods 218

Class Events 220

Class-Level Constants 222

Building and Using a Sample VBScript Class 223

Summary 232

Chapter 9: Regular Expressions 233

Introduction to Regular Expressions 233

The RegExp Object 238

The Matches Collection 252

A Few Examples 256

Summary 259

Chapter 10: Client-Side Web Scripting 261

Tools of the Trade 261

The Evolution of Scripting 262

Different Scripting Languages 263

Responding to Browser Events 265

The Document Object Model in Action 280

Summary 286

Chapter 11: Windows Sidebars and Gadgets 287

Gadget Basics 288

Building a Gadget 292

Auto-Refresh a Gadget 305

Packaging the Gadget 307

Summary 307

Chapter 12: Task Scheduler Scripting 309

Working with Task Scheduler 310

Task Scheduler 2.0 Scripting Objects 314

Sample Task Scheduler Script 340

Summary 344

Chapter 13: PowerShell 345

Requirements 345

Features 346

Why a New Scripting Language? 346

Getting Started 347

Working with Scripts in PowerShell 356

Creating and Calling Your First PowerShell Cmdlet Script 357

The Connection Between VBScript and PowerShell? 359

Summary 373

Chapter 14: Super-Charged Client-Side Scripting 375

Requirements and Browser Security 375

Scriptlets — Ancestors of Behaviors 376

Event Management 384

Scriptlets Are Deprecated in IE5 389

HTML Components (HTCs) 392

Summary 402

Chapter 15: Windows Script Host 405

Tools of the Trade 406

What Is WSH? 406

Types of Script Files 408

Running Scripts with the Windows Script Host 408

Using .WSH Files to Launch Scripts 411

Windows Script Host Intrinsic Objects 412

Summary 464

Chapter 16: Windows Script Components 465

What Are Windows Script Components? 465

What Tools Do You Need? 466

The Script Component Runtime 466

Script Component Files and Wizard 467

Exposing Properties, Methods, and Events 473

Registration Information 478

Creating the Script Component Type Libraries 479

How to Reference Other Components 481

Script Components for ASP 482

Compile-Time Error Checking 484

Using VBScript Classes in Script Components 484

Summary 488

Chapter 17: Script Encoding 489

Limitations of Script Encoding 490

Encoded Scripts — Dos and Don’ts 490

Encoding with the Microsoft Script Encoder 491

Decoding the Script 507

Other Methods of Script Obfuscation 507

Summary 508

Chapter 18: Remote Scripting 509

How Remote Scripting Works 509

Using VBScript for Remote Scripting 511

Summary 516

Chapter 19: HTML Applications 517

The Advantage of an HTML Application 517

How to Create a Basic HTA 518

The HTA:APPLICATION Element 522

HTAs and Security 527

HTA Deployment Models 530

What Isn’t Supported with HTAs? 532

Summary 533

Chapter 20: Server-Side Web Scripting 535

Understanding the Anatomy of the HTTP Protocol 536

Introducing Active Server Pages 540

Using the Active Server Pages Object Model 544

Using Active Server Pages Effectively 559

Summary 567

Chapter 21: Adding VBScript to Your VB and .NET Applications 569

Why Add Scripting to Your Application? 570

Macro and Scripting Concepts 570

Adding the Script Control to a VB 6 or .NET Application 572

Script Control Reference 573

Error Handling with the Script Control 592

Debugging 595

Using Encoded Scripts 596

Sample .NET Project 596

Sample Visual Basic 6 Project 597

Summary 602

Appendix A: VBScript Functions and Keywords 603

Appendix B: Variable Naming Convention 675

Appendix C: Coding Conventions 677

Appendix D: Visual Basic Constants Supported in VBScript 681

Appendix E: VBScript Error Codes and the Err Object 687

Appendix F: The Scripting Runtime Library Object Reference 703

Appendix G: The Windows Script Host Object Model 715

Appendix H: Regular Expressions 723

Appendix I: The Variant Subtypes 727

Appendix J: ActiveX Data Objects 731

Index 759

loading