Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Microsoft vbscript professional projects
PREMIUM
Số trang
961
Kích thước
13.4 MB
Định dạng
PDF
Lượt xem
1688

Microsoft vbscript professional projects

Nội dung xem thử

Mô tả chi tiết

Microsoft®

VBScript

Professional Projects

This page intentionally left blank

Jerry Lee Ford, Jr.

Microsoft®

VBScript

Professional Projects

TM

SVP, Retail and Strategic

Market Group:

Andy Shafran

Publisher:

Stacy L. Hiquet

Senior Marketing Manager:

Sarah O’Donnell

Marketing Manager:

Heather Hurley

Manager of Editorial Services:

Heather Talbot

Acquisitions Editor:

Todd Jensen

Associate Marketing Manager:

Kristin Eisenzopf

Project Editor:

Argosy

Technical Reviewer:

Zac Hester

Retail Market Coordinator:

Sarah Dubois

Copy Editor:

Ginny Kaczmarek

Interior Layout:

Argosy

Cover Designer:

Mike Tanamachi

Indexer:

Elizabeth Hoff

Proofreader:

Christopher Mattison

©2003 by Premier Press, a division of Course Technology. All rights reserved.

No part of this book may be reproduced or transmitted in any form or by any

means, electronic or mechanical, including photocopying, recording, or by any

information storage or retrieval system without written permission from Pre￾mier Press, except for the inclusion of brief quotations in a review.

The Premier Press logo and related trade dress are trademarks of

Premier Press and may not be used without written permission.

Microsoft is a registered trademark of Microsoft Corporation in the United

States and/or other countries.

All other trademarks are the property of their respective owners.

Important: Premier Press cannot provide software support. Please contact

the appropriate software manufacturer’s technical support line or Web site

for assistance.

Premier Press and the author have attempted throughout this book to dis￾tinguish proprietary trademarks from descriptive terms by following the cap￾italization style used by the manufacturer.

Information contained in this book has been obtained by Premier Press from

sources believed to be reliable. However, because of the possibility of human

or mechanical error by our sources, Premier Press, or others, the Publisher

does not guarantee the accuracy, adequacy, or completeness of any informa￾tion and is not responsible for any errors or omissions or the results obtained

from use of such information. Readers should be particularly aware of the

fact that the Internet is an ever-changing entity. Some facts may have

changed since this book went to press.

ISBN: 1-59200-056-8

Library of Congress Catalog Card Number: 2003104025

Printed in the United States of America

03 04 05 06 07 BH 10 9 8 7 6 5 4 3 2 1

Premier Press, a division of Course Technology

25 Thomson Place

Boston, MA 02210

TM

Dedication

To Alexander, William, Molly, and Mary.

This page intentionally left blank

Acknowledgments

There are a number of people who deserve a lot of credit for their hard work on

this book. I especially want to thank Todd Jensen for working with me as the

book’s acquisitions editor on yet another writing project. I also want to thank the

book’s project editor, Alex Bilsky, as well as its copy editor, Ginny Kaczmarek, for

their excellence. Finally, I wish to thank Zac Hester, the book’s technical editor,

who has now worked with me on four different books.

This page intentionally left blank

About the Author

Jerry Lee Ford, Jr., is an author, educator, and IT professional with 15 years of

experience in information technology, including roles as an automation analyst, a

technical manager, a technical support analyst, an automation engineer, and a

security analyst. Jerry is an MCSE and has also earned Microsoft’s MCP and

MCP + Internet certifications. In addition, he has a master’s degree in business

administration from Virginia Commonwealth University in Richmond, Virginia.

Jerry is also the author of 11 other books, including Learn JavaScript in a Week￾end, Learn VBScript in a Weekend, Microsoft Windows Shell Scripting and WSH

Administrator’s Guide, Microsoft WSH and VBScript for the Absolute Beginner, and

Microsoft Windows XP Professional Administrator’s Guide. He has over five years of

experience as an adjunct instructor teaching networking courses in information

technology. Jerry lives in Richmond, Virginia, with his wife, Mary, and their chil￾dren, Alexander, William, and Molly.

This page intentionally left blank

Contents at a Glance

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxv

Part I Introducing Microsoft VBScript . . . . . . . . . . . . 1

1 What Is VBScript? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Errors, Constants, and Variables . . . . . . . . . . . . . . . . . . . . 27

3 Conditional Logic and Iterative Structures . . . . . . . . . . . . 53

4 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

5 Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

6 Data Collection, Notification, and Error Reporting . . . . . 119

7 VBScript Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

8 VBScript and Internet Explorer. . . . . . . . . . . . . . . . . . . . 167

9 VBScript and the WSH . . . . . . . . . . . . . . . . . . . . . . . . . 195

Part II Professional Project 1:

Desktop Administration Using VBScript

and the WSH . . . . . . . . . . . . . . . . . . . . . . . . 221

10 Project Case Study: Desktop Customization and

Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

11 Customizing the Desktop . . . . . . . . . . . . . . . . . . . . . . . . 243

12 Customizing the Start Menu and Quick Launch Toolbar. 269

13 Scheduling Disk Maintenance . . . . . . . . . . . . . . . . . . . . . 291

14 Mapping Network Printers and Disks . . . . . . . . . . . . . . 313

15 Creating Administrator Accounts . . . . . . . . . . . . . . . . . . 337

Part III Professional Project 2:

Analyzing Application Logs . . . . . . . . . . . . . 361

16 Project Case Study: Analyzing Application Logs . . . . . . . 365

17 Using Configuration Files to Control Script Execution . . 379

18 Developing Script Log Analyzers . . . . . . . . . . . . . . . . . . 397

19 Scheduling Script Execution . . . . . . . . . . . . . . . . . . . . . . 437

20 Maintaining a 30-Day Summary Log Archive. . . . . . . . . 453

Part IV Professional Project 3:

Creating a Centralized Report Management

Station . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

21 Project Case Study: Creating a Centralized Report

Management Station. . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

22 Developing a Setup Script . . . . . . . . . . . . . . . . . . . . . . . . 485

23 Collecting Remote Summary Reports . . . . . . . . . . . . . . . 507

24 Processing and Consolidating Report Data . . . . . . . . . . . 537

25 Archive Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 589

Part V Professional Project 4:

Reporting Application Summary Data via

the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613

26 Reporting Application Summary Data via the Web . . . . 617

27 Designing the Web Site . . . . . . . . . . . . . . . . . . . . . . . . . 633

28 Building the Web Site’s Main Page . . . . . . . . . . . . . . . . . 645

29 Building the Registration and Configuration

Settings Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669

30 Converting Reports to HTML Pages . . . . . . . . . . . . . . . 691

31 Building the Report Archive Page . . . . . . . . . . . . . . . . . . 729

32 Report Distribution and Remote Archive Management . . 755

Part VI Appendices . . . . . . . . . . . . . . . . . . . . . . . . . 791

A Windows XP Command Reference . . . . . . . . . . . . . . . . . 793

B What’s on the Companion Web Site . . . . . . . . . . . . . . . . 899

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903

xii Contents at a Glance

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxv

Goal of This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxv

What You Need to Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxvi

Conventions Used in This Book . . . . . . . . . . . . . . . . . . . . . . . xxxvi

PART I INTRODUCING MICROSOFT VBSCRIPT . . . . . 1

Chapter 1 What Is VBScript? . . . . . . . . . . . . . . . . . . . . . . 3

Introducing VBScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

History of VBScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Visual Basic Family of Programming Languages . . . . . . . . . . . 6

Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Visual Basic for Applications . . . . . . . . . . . . . . . . . . . . . . . 8

VBScript Execution Environments . . . . . . . . . . . . . . . . . . . . . 9

VBScript Web Page Development . . . . . . . . . . . . . . . . . . . . . . . . 9

Compatible Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Adding VBScript to Web Pages . . . . . . . . . . . . . . . . . . . . . . . 11

Loading VBScripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Responding to Events . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Referencing External Scripts . . . . . . . . . . . . . . . . . . . . . . 17

The WSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

WSH Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Scripting Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Execution Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

The Core Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Writing WSH VBScripts . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

The Windows Command Prompt . . . . . . . . . . . . . . . . . . . . . 23

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Chapter 2 Errors, Constants, and Variables . . . . . . . . . . 27

VBScript Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

VBScript Statement Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Syntax Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Displaying Syntax Errors within Internet Explorer . . . . . . . . 33

Documenting VBScripts with Comments . . . . . . . . . . . . . . . . . 35

Storing and Retrieving Data from Memory . . . . . . . . . . . . . . . . 38

Using Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Defining Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Referencing VBScript Run-Time Constants . . . . . . . . . . . 40

Creating Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Variable Naming Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Defining Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Variable Scope and Lifetime . . . . . . . . . . . . . . . . . . . . . . . 47

Other Sources of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Using Operators to Manipulate Variables . . . . . . . . . . . . . . . . . . 48

VBScript Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Chapter 3 Conditional Logic and Iterative Structures. . . 53

Comparison Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

The If Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

If Statement Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Advanced Comparison Operations . . . . . . . . . . . . . . . . . . 55

Alternative Forms of the If Statement . . . . . . . . . . . . . . . 56

Nesting Multiple If Statements . . . . . . . . . . . . . . . . . . . . 57

The Select Case Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Working with Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Do…While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Do…Until . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

For…Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

While…Wend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

xiv Contents

Tải ngay đi em, còn do dự, trời tối mất!