Tải bản đầy đủ (.pdf) (554 trang)

windows administration at the command line for windows 2003, windows xp, and windows 2000 (2006)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (15.13 MB, 554 trang )


Wiley Publishing, Inc.

Windows

®

Administration
at the Command Line

for Windows

®

2003, Windows

®

XP,
and Windows

®

2000

John Paul Mueller

10002.book Page iii Friday, March 10, 2006 11:18 PM

Windows



®

Administration
at the Command Line

for Windows

®

2003, Windows

®

XP,
and Windows

®

2000

10002.book Page i Friday, March 10, 2006 11:18 PM

10002.book Page ii Friday, March 10, 2006 11:18 PM

Wiley Publishing, Inc.

Windows

®


Administration
at the Command Line

for Windows

®

2003, Windows

®

XP,
and Windows

®

2000

John Paul Mueller

10002.book Page iii Friday, March 10, 2006 11:18 PM

Acquisitions and Development Editor: Thomas Cirtin
Technical Editor: Russ Mullen
Production Editor: Martine Dardignac
Copy Editor: Cheryl Hauser
Production Manager: Tim Tate
Vice President and Executive Group Publisher: Richard Swadley
Vice President and Executive Publisher: Joseph B. Wikert

Vice President and Publisher: Neil Edde
Book Designers: Maureen Forys, Happenstance Type-O-Rama, Judy Fung
Compositor: Craig Woods, Happenstance Type-O-Rama
Proofreader: Nancy Riddiough
Indexer: Nancy Guenther
Cover Designer: Ryan Sneed
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN-13: 978-0-4700-1000-6
ISBN-10: 0-4700-1000-2
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-
copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to
the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianap-
olis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the
accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties
of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strat-
egies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not
engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a compe-
tent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact
that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean
that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make.
Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this
work was written and when it is read.
For general information on our other products and services or to obtain technical support, please contact our Customer Care Depart-
ment within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Library of Congress Cataloging-in-Publication Data is available from the publisher.
TRADEMARKS: Wiley, the Wiley logo, and the Sybex logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or

its affiliates, in the United States and other countries, and may not be used without written permission. Microsoft and Windows are reg-
istered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1

10002.book Page iv Friday, March 10, 2006 11:18 PM

This book is dedicated to Peg and Scott
Conderman, good friends who have
helped me realize my dreams of
self-sufficiency.

10002.book Page v Friday, March 10, 2006 11:18 PM

Acknowledgments

Thanks to my wife, Rebecca, for working with me to get this book completed. I really don’t know
what I would have done without her help in researching and compiling some of the information
that appears in this book. She also did a fine job of proofreading my rough draft and page proofing
the result. Rebecca also helps a great deal with the glossary and keeps the house running while I’m
buried in work.
Russ Mullen deserves thanks for his technical edit of this book. He greatly added to the accuracy
and depth of the material you see here. Russ is always providing me with great URLs for new prod-
ucts and ideas. However, it’s the testing Russ does that helps most. He’s the sanity check for my
work. Russ also has different computer equipment from mine, so he’s able to point out flaws that
I might not otherwise notice.
A number of people read all or part of this book to help me refine the approach, test the coding
examples, and generally provide input that all readers wish they could have. These unpaid volun-
teers helped in ways too numerous to mention here. I especially appreciate the efforts of Eva Beattie,

who read the entire book and selflessly devoted herself to this project. Edward Antrobus provided
significant technical input and I don’t know what I’d do without him. He questioned a good many of
my assumptions and in doing so, made the book significantly better.
Finally, I would like to thank Tom Cirtin, Martine Dardignac, Cheryl Hauser, Nancy Riddiough,
and the rest of the editorial and production staff at Sybex for their assistance in bringing this book
to print. It’s always nice to work with such a great group of professionals and I very much appre-
ciate the friendship we’ve built over the last six books.

10002.book Page vi Friday, March 10, 2006 11:18 PM

About the Author

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced
69 books and over 300 articles to date. The topics range from networking to artificial intelligence and
from database management to heads down programming. Some of his current books include a Win-
dows power optimization book, a book on .NET security, and books on Amazon Web Services, Goo-
gle Web Services, and eBay Web Services. His technical editing skills have helped over 42 authors
refine the content of their manuscripts. John has provided technical editing services to both

Data Based
Advisor

and

Coast Compute

magazines. He’s also contributed articles to magazines like

DevSource,
InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software

Test and Performance

, and

Visual Basic Developer

. He’s currently the editor of the .NET electronic news-
letter for Pinnacle Publishing (

/>
).
When John isn’t working at the computer, you can find him in his workshop. He’s an avid
woodworker and candle maker. On any given afternoon, you can find him working at a lathe or
putting the finishing touches on a bookcase. He also likes making glycerin soap and candles, which
comes in handy for gift baskets. You can reach John on the Internet at



. John is
also setting up a Web site at

/>
/. Feel free to look and make sug-
gestions on how he can improve it. One of his current projects is creating book FAQ sheets that
should help you find the book information you need much faster.

10002.book Page vii Friday, March 10, 2006 11:18 PM

10002.book Page viii Friday, March 10, 2006 11:18 PM


Contents at a Glance

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Part 1 • Standard Windows Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

Chapter 1 • Using the Command Line Effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2 • Completing Data-Specific Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 3 • Discovering the System Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Chapter 4 • Locating Files and Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Chapter 5 • Securing and Monitoring a System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Chapter 6 • Using Developer and Low Level Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . 197

Part 2 • Using Windows Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237

Chapter 7 • Creating CMD and BAT Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Chapter 8 • Working with Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Chapter 9 • Scripting for Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Chapter 10 • Using Task Scheduler Effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Chapter 11 • After Hours Automation Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Part 3 • Relying on Third Party Automation. . . . . . . . . . . . . . . . . . . . . . . . . . . . .365

Chapter 12 • Obtaining Command Prompt Enhancers . . . . . . . . . . . . . . . . . . . . . . . . . 367
Chapter 13 • Increasing Productivity at the Command Line . . . . . . . . . . . . . . . . . . . . . 379
Chapter 14 • Editing and Compiling Batch Files and Scripts . . . . . . . . . . . . . . . . . . . . 389

10002.book Page ix Friday, March 10, 2006 11:18 PM

x


CONTENTS AT A GLANCE



Part 4 • Working with the .NET Framework Utilities . . . . . . . . . . . . . . . . . . . . .403

Chapter 15 • Understanding the .NET Framework Versions . . . . . . . . . . . . . . . . . . . . 405
Chapter 16 • Configuring the .NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Chapter 17 • Configuring ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

Part 5 • Windows Vista Special Features Preview . . . . . . . . . . . . . . . . . . . . . . . .453

Chapter 18 • Using the Enhanced Vista Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Chapter 19 • Working with Monad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Appendix • 52 Indispensable Command Line Tricks and Techniques . . . . . . . . . . . . 485

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509

10002.book Page x Friday, March 10, 2006 11:18 PM

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Part 1 • Standard Windows Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1 • Using the Command Line Effectively . . . . . . . . . . . . . . . . . . . . . . . . . 3

Understanding Why the Command Line Is So Important . . . . . . . . . . . . . . . . . . . . . . . . . 4

The Command Line Made Easy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Using Utilities Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Writing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Scheduling Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Relying on Third Party Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Viewing the Commands by Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Data specific . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
System Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
File and Resource Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Security and System Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Developer and Low-level Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Task Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Updating Your Current Utilities at the Microsoft Download Center . . . . . . . . . . . . . . . 12
Configuring the Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Setting the Window Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Changing the Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Choosing a Window Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Defining the Text Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Placing a Command Prompt at Your Fingertips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Understanding Internal Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Chapter 2 • Completing Data-Specific Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Creating and Modifying Data Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Opening Remote Directories with the Append Utility . . . . . . . . . . . . . . . . . . . . . . . . 20
Copying Files with the


Copy

Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Removing Files with the

Del

and

Erase

Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Removing a Directory Tree with the

DelTree

Command . . . . . . . . . . . . . . . . . . . . . . . 24
Modifying Files with the Edlin Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Repairing System Databases with the ESEnTUtl Utility . . . . . . . . . . . . . . . . . . . . . . . 25
Decompressing Files with the Expand Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Creating Directories with the

MD

and

MkDir

Commands . . . . . . . . . . . . . . . . . . . . . 31
Moving Files and Renaming Files and Directories with

the

Move

Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

10002.book Page xi Friday, March 10, 2006 11:18 PM

xii

CONTENTS



Setting and Viewing Application Paths with the

Path

Command . . . . . . . . . . . . . . . 33
Storing and Retrieving Directories with the

PushD


and

PopD

Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Recovering Lost Files with the Recover Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Removing a Directory with the

RD

and

RmDir

Commands . . . . . . . . . . . . . . . . . . . . 35
Renaming a File or Directory with the

Ren

and

Rename

Commands . . . . . . . . . . . . . 36
Replacing Existing Files with the Replace Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Sorting File Content with the Sort Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Associating a Folder to a Drive with the Subst Utility . . . . . . . . . . . . . . . . . . . . . . . . . 38
Displaying a Directory Structure with the Tree Utility . . . . . . . . . . . . . . . . . . . . . . . . 39
Validating File Operations with the

Verify

Command . . . . . . . . . . . . . . . . . . . . . . . . . 40
Performing Bulk File Transfers with the XCopy Utility . . . . . . . . . . . . . . . . . . . . . . . 40
Displaying Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Working with Line Printers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Printing Data Files with the Print Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Outputting Data Files with the

Type

Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Performing a Formatted Printout with Notepad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Determining File and Directory Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Determining the Current Directory and Changing Directories
with the

CD

and

ChDir

Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Comparing Two Files with the Comp Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Performing Advanced File Comparison with the FC Utility . . . . . . . . . . . . . . . . . . . 51
Working with File Associations and Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Performing Backups with the NTBackup Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Working with ODBC Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Configuring the ODBC Environment with the ODBCConf Utility . . . . . . . . . . . . . . 56
Creating an ODBC Data Source at the Command Line . . . . . . . . . . . . . . . . . . . . . . . . 58
Managing the Windows Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Modifying the Registry with the RegEdit Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Scripting Registry Entries with the RegIni Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Adding and Removing Servers with the RegSvr32 Utility . . . . . . . . . . . . . . . . . . . . . 61
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61


Chapter 3 • Discovering the System Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Getting System Status Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Obtaining Driver Information with the DriverQuery Utility . . . . . . . . . . . . . . . . . . . 64
Obtaining DirectX Status with the DXDiag Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Monitoring the File System with the FSUtil Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Managing Volume Labels with the Label Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Determining Memory Status with the Mem Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Obtaining General System Information with the MSInfo32 Utility . . . . . . . . . . . . . . 76
Managing Environment Variables with the

Set

Command . . . . . . . . . . . . . . . . . . . . . 78
Determining the Operating System Version with the

Ver

Command . . . . . . . . . . . . 81
Getting Volume Information with the

Vol

Command . . . . . . . . . . . . . . . . . . . . . . . . . 81
Viewing the Volume Shadow Service Data with the
VSSAdmin Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

10002.book Page xii Friday, March 10, 2006 11:18 PM


CONTENTS

xiii

Recording System Status Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Managing System Events with the EventCreate Utility . . . . . . . . . . . . . . . . . . . . . . . . 82
Triggering System Events with the EventTriggers Utility . . . . . . . . . . . . . . . . . . . . . 83
Working with Performance Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Adding Performance Counters with the LodCtr Utility . . . . . . . . . . . . . . . . . . . . . . . 87
Managing Performance Logs and Alerts with the LogMan Utility . . . . . . . . . . . . . . 88
Viewing the Results of Changes with the PerfMon Utility . . . . . . . . . . . . . . . . . . . . . 91
Reconfiguring Performance Logs with the ReLog Utility . . . . . . . . . . . . . . . . . . . . . . 92
Tracking Performance with the TypePerf Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Removing Performance Counters with the UnlodCtr Utility . . . . . . . . . . . . . . . . . . . 94
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Chapter 4 • Locating Files and Other Resources. . . . . . . . . . . . . . . . . . . . . . . . . . 97

Locating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Finding Files and Directories with the

Dir

Command . . . . . . . . . . . . . . . . . . . . . . . . . 98
Detecting Shared Open Files with the OpenFiles Utility . . . . . . . . . . . . . . . . . . . . . . 100
Locating Information in Files with the Find and FindStr Utilities . . . . . . . . . . . . . . 102
Monitoring Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Changing File and Directory Attributes with the Attrib Utility . . . . . . . . . . . . . . . . 105
Changing File and Directory Access with the CACLs Utility . . . . . . . . . . . . . . . . . . 107
Determining File and Directory Status with the ChkDsk Utility . . . . . . . . . . . . . . . 109

Performing Boot Time Disk Checks with the ChkNTFS Utility . . . . . . . . . . . . . . . . 110
Encrypting Data with the Cipher Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Compressing Data with the Compact Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Working with Other Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Converting Program Groups with the GrpConv Utility . . . . . . . . . . . . . . . . . . . . . . 114
Managing Power Settings with the PowerCfg Utility . . . . . . . . . . . . . . . . . . . . . . . . 115
Working with Terminal Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Working with Remote Access Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Setting Up a Telephony Client with the TCMSetup Utility . . . . . . . . . . . . . . . . . . . 126
Communicating with Telnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Managing the System Time with the W32Tm Utility . . . . . . . . . . . . . . . . . . . . . . . . . 130
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Chapter 5 • Securing and Monitoring a System. . . . . . . . . . . . . . . . . . . . . . . . . 135

Working with the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Managing the ATM Call Manager with the ATMAdm Utility . . . . . . . . . . . . . . . . . 136
Getting the Media Access Control Information with the GetMAC Utility . . . . . . . 136
Getting the NetWare Routing Information with the IPXRoute Utility . . . . . . . . . . 137
Managing WinHTTP Proxy Configuration with the ProxyCfg Utility . . . . . . . . . . 138
Managing the Network with the Net Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Discovering TCP/IP Diagnostic Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Managing FTP Servers with the FTP Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Working with Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Monitoring Users with the AuditUsr Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Configuring Profiles the CMStP Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Obtaining Group Policy Results with the GPResult Utility . . . . . . . . . . . . . . . . . . . 174

10002.book Page xiii Friday, March 10, 2006 11:18 PM


xiv

CONTENTS



Managing Group Policies with the GPUpdate Utility . . . . . . . . . . . . . . . . . . . . . . . . 175
Sending Messages with the Msg Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Virus and External Intrusion Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Removing Viruses with the BlastCln Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Managing the File System with the FltMC Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Detect and Remove Malicious Software with the MRT Utility . . . . . . . . . . . . . . . . . 180
Verifying System Files with the SFC Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Verifying Drivers with the Verifier Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Configuring the System Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Managing the Boot Configuration with the BootCfg Utility . . . . . . . . . . . . . . . . . . . 183
Configuring Local Security Policies with the SecEdit Utility . . . . . . . . . . . . . . . . . . 185
Add and Removing Applications with the SysOCMgr Utility . . . . . . . . . . . . . . . . . 186
Getting System Configuration Information with the SystemInfo Utility . . . . . . . . 187
Interacting with the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Converting IIS Logs with the ConvLog Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Monitoring and Managing IIS with the IISReset Utility . . . . . . . . . . . . . . . . . . . . . . 189
Working with IP Version 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Working with General Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Terminating Tasks with the TaskKill Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Listing Applications and Services with the TaskList Utility . . . . . . . . . . . . . . . . . . . 193
Converting Event Trace Logs with the TraceRpt Utility . . . . . . . . . . . . . . . . . . . . . . . . . 194
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Chapter 6 • Using Developer and Low Level Utilities. . . . . . . . . . . . . . . . . . . . . 197


Working with Automated System Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Backing Up and Restoring System Data with the ASR_Fmt Utility . . . . . . . . . . . . 200
Working with Logical Disks Using the ASR_LDM Utility . . . . . . . . . . . . . . . . . . . . 200
Working with Protected Files Using the ASR_PFU Utility . . . . . . . . . . . . . . . . . . . . 200
Using the

Start

Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Performing Disk Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Managing Removable Storage with the RSM Utility . . . . . . . . . . . . . . . . . . . . . . . . . 203
Converting FAT Partitions to NTFS with the Convert Utility . . . . . . . . . . . . . . . . . 209
Improving Disk Access Performance with the Defrag Utility . . . . . . . . . . . . . . . . . 210
Compressing Files with the Diantz and MakeCAB Utilities . . . . . . . . . . . . . . . . . . . 210
Managing Partitions with the DiskPart Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Mounting a Volume with the MountVol Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Managing Disk Performance with the DiskPerf Utility . . . . . . . . . . . . . . . . . . . . . . . 217
Employing Low Level Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Examining, Modifying, and Debugging Files with the Debug Utility . . . . . . . . . . 218
Converting Executables with the Exe2Bin Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Ensuring Proper Application Execution with the ForceDOS Utility . . . . . . . . . . . . 219
Terminating a Session Using the Logoff Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Performing System-Level Debugging with the NTSD Utility . . . . . . . . . . . . . . . . . 220
Managing Compatibility Databases with SDBInst . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Accessing Functions within DLLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Uninstalling the Operating System with the OSUninst Utility . . . . . . . . . . . . . . . . . . . 226
Controlling Services with the SC Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Shutting Down the System with the ShutDown Utility . . . . . . . . . . . . . . . . . . . . . . . . . 230


10002.book Page xiv Friday, March 10, 2006 11:18 PM

CONTENTS

xv

Replicating COM+ Applications with the COMRepl Utility . . . . . . . . . . . . . . . . . . . . . 232
Managing Type Libraries with the RegTLib Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Saving and Restoring System Restore Data with the SRDiag Utility . . . . . . . . . . . . . . 233
Performing Web-Based Enterprise Management Tasks . . . . . . . . . . . . . . . . . . . . . . . . . 233
Administering Managed Object Format Files with the MOFComp Utility . . . . . . 234
Interacting with the WBEM Server with the WinMgmt Utility . . . . . . . . . . . . . . . . 235
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

Part 2 • Using Windows Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Chapter 7 • Creating CMD and BAT Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

Starting the Command Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Using the CMD Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Modifying Config.NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Modifying AutoExec.NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Modifying Application Behavior Using a PIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Defining Application Compatibility with the SetVer Utility . . . . . . . . . . . . . . . . . . 256
Using Common DOS Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Working at the Command Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Clearing the Display with the CLS Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Changing Screen Colors with the Color Command . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Working with the System Date Using the Date Command . . . . . . . . . . . . . . . . . . . 264
Tracking Command Line Actions with the DosKey Utility . . . . . . . . . . . . . . . . . . . 265
Obtaining Command Line Help with the Help Utility . . . . . . . . . . . . . . . . . . . . . . . 267

Working with the System Time Using the Time Command . . . . . . . . . . . . . . . . . . . 267
Changing the Command Window Title with the Title Command . . . . . . . . . . . . . 267
Creating Batch Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Using the Call Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Using the Choice Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Using the Echo Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Using the Exit Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Using the For Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Using the Goto Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Using the If Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Using the Pause Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Using the Prompt Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Using the Rem Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Using the Shift Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

Chapter 8 • Working with Scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

Understanding Scripting Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Learning the Basics of JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Learning the Basics of VBScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Executing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Running Scripts with the CScript and WScript Utilities . . . . . . . . . . . . . . . . . . . . . . 284
Configuring the Host and Property Page Options . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

10002.book Page xv Friday, March 10, 2006 11:18 PM

xvi

CONTENTS




Scripting Networking Solutions with the NetSH Utility . . . . . . . . . . . . . . . . . . . . . . . . 286
Creating a Basic Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Scripting the Command Line and System Environment . . . . . . . . . . . . . . . . . . . . . . 292
Scripting the Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Using the Scripting Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Working with the WScript Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Working with the WScript.WshArguments Object . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Working with the WScript.WshShell Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Working with the WScript.WshNetwork Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Impersonating a User with the RunAs Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Chapter 9 • Scripting for Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

Discovering Helpful Active Directory Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Managing Active Directory with the DSQuery Utility . . . . . . . . . . . . . . . . . . . . . . . 305
Managing the Active Directory Database with the NTDSUtil Utility . . . . . . . . . . . 311
Working with Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Creating New Objects Using the DSAdd Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Listing Objects Using the DSGet Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Editing Existing Objects Using the DSMod Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Moving Existing Objects Using the DSMove Utility . . . . . . . . . . . . . . . . . . . . . . . . . 322
Deleting Objects Using the DSRm Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Working with Users, Groups, and Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Obtaining a User’s Logon Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Obtaining a User’s Full Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Discovering User Group Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Resetting a User’s Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Displaying a List of Hostnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

Chapter 10 • Using Task Scheduler Effectively. . . . . . . . . . . . . . . . . . . . . . . . . . 327

Starting and Stopping the Task Scheduler Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Managing Tasks with the SchTasks Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Working with the AT Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Combining the AT Utility with Batch Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Creating Script-Based Scheduler Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

Chapter 11 • After Hours Automation Scripting . . . . . . . . . . . . . . . . . . . . . . . . 339

Defining After Hours Task Candidates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Creating Message Queue Backups with the MQBkup Utility . . . . . . . . . . . . . . . . . 341
Installing Applications with the MSIExec Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Designing and Testing the After Hours Batch File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Adding Debug Information to Batch Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Identifying Batch Files and Their Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Using a Centralized Data Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

10002.book Page xvi Friday, March 10, 2006 11:18 PM

CONTENTS

xvii

Designing and Testing the After Hours Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

Mapping a Network Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Creating a CSV File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Creating Remote Connections with the MSTSC Utility . . . . . . . . . . . . . . . . . . . . . . . . . 360
Providing Fault Tolerance for an After Hours Batch or Script . . . . . . . . . . . . . . . . . . . . 360
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

Part 3 • Relying on Third Party Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Chapter 12 • Obtaining Command Prompt Enhancers . . . . . . . . . . . . . . . . . . . 367

Using XVI32 to View Files in Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Moving Data with Send To Toys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Checking File Integrity Using FCIV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Getting the Better XCopy with XXCopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Working with Shell Extensions Using ShellExView . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

Chapter 13 • Increasing Productivity at the Command Line. . . . . . . . . . . . . . . 379

Obtaining Additional Information with ToggIt Command Line Helper . . . . . . . . . . . 380
Using Quick Shutdown to End a Session Fast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Creating a Friendlier Interface with PromptPal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Getting a More Functional Command Line with WinOne . . . . . . . . . . . . . . . . . . . . . . . 384
Automating Email Using sendEmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

Chapter 14 • Editing and Compiling Batch Files and Scripts . . . . . . . . . . . . . . 389

Editing All File Types with WinVi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
Obtaining a Better Notepad with Notepad+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Creating Executable Batch Files with Batch File Compiler 5.2 . . . . . . . . . . . . . . . . . . . . 393

Develop and Compile Batch Files with Quick Batch File Compiler . . . . . . . . . . . . . . . 394
Understanding JavaScript and VBScript Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Understanding the JSC Compiler Supplied with .NET . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Using the JSC Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Creating a Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Working with the .NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

Part 4 • Working with the .NET Framework Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Chapter 15 • Understanding the .NET Framework Versions . . . . . . . . . . . . . . 405

Locating the .NET Framework on Your System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Understanding the Concept of Side-by-Side Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Viewing the Assembly Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Discovering the Essential .NET Framework Assemblies . . . . . . . . . . . . . . . . . . . . . . . . 414
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

10002.book Page xvii Friday, March 10, 2006 11:18 PM

xviii

CONTENTS



Chapter 16 • Configuring the .NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . 417

Understanding .NET Framework Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Working with the Global Assembly Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Understanding .NET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Working with Code Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Creating and Defining Permission Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Defining Policy Assemblies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Adding Configured Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Understanding the Use of CONFIG Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Setting Policies Using the CASPol Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Placing Assemblies in the Global Assembly Cache with GACUtil . . . . . . . . . . . . . . . . 431
Installing Assemblies with the InstallUtil Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Registering Assemblies with the RegAsm Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Registering Services with the RegSvcs Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434

Chapter 17 • Configuring ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

Locating ASP.NET Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Fixing Application Registration Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Fixing File Association Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Fixing Configuration Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Creating Web Applications with the ASPNet_Compiler Utility . . . . . . . . . . . . . . . . . . 442
Providing Multiple Browser Support with the ASPNet_RegBrowsers Utility . . . . . . 443
Adding ASP.NET Support to IIS with the ASPNet_RegIIS Utility . . . . . . . . . . . . . . . . 444
Adding ASP.NET Support to SQL Server with the
ASPNet_RegSQL Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Using the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Working with the ASPNet_RegSQL Utility Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Understanding the ASPNet_State Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

Part 5 • Windows Vista Special Features Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Chapter 18 • Using the Enhanced Vista Utilities . . . . . . . . . . . . . . . . . . . . . . . . 455


Understanding How Vista Changes Existing Commands and Utilities . . . . . . . . . . . . 455
Understanding the Monad Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Using the New Vista Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468

Chapter 19 • Working with Monad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

Using the MSH Command Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Creating a Shell Extension with the Make-Shell Utility . . . . . . . . . . . . . . . . . . . . . . . . . 472
Creating a Monad Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Creating a Simple Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Running the Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

10002.book Page xviii Friday, March 10, 2006 11:18 PM

CONTENTS

xix

Creating a Monad Cmdlet and Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Creating the Cmdlet Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Compiling the Cmdlet Executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Using the Make-Shell Utility to Create the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Getting Started with Command Line Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

Appendix • 52 Indispensable Command Line Tricks and Techniques . . . . . . . 485

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509


10002.book Page xix Friday, March 10, 2006 11:18 PM

10002.book Page xx Friday, March 10, 2006 11:18 PM

Introduction

When was the last time you visited the command line? A few administrators live there, but many
others have forgotten about it over the years. When Microsoft originally introduced Windows, the
assumption was that you no longer needed the command line and many people left it behind com-
pletely. After all, why bother with the command line when you can access everything you need
from the graphical environment? The problem is that the Windows Graphical User Interface (GUI)
doesn’t actually provide access to everything on your system. In addition, all of that mousing
around wastes considerable time and effort. You can’t easily replicate your actions either; many
people have tried, and failed, to produce a macro recorder for the graphical portion of Windows.
Every time that you want to perform a task, you start it from scratch, which means that you have
plenty of opportunities for making mistakes.

Windows Administration at the Command Line

reveals
the command line to you. Using the information in this book, you not only discover the vast array
of commands that are at your disposal, but you also see how to automate those commands so that
you can save significant time and effort while performing administrative tasks.

Overcoming GUI Problems

As an example of the flawed behavior of the GUI, just try locating the word

Microsoft


in the exe-
cutables on your hard drive. You’ll find that the task is impossible because Windows doesn’t
search executables and just barely searches data files. Many people have complained about the
flawed performance of the search mechanism in Windows. Many people end up getting third
party utilities to help them search for the data that Windows should help them find, utilities with
dubious reputations for compromising security.

Windows Administration at the Command Line


shows you a better way, one that relies on a free utility supplied with Windows that will never
divulge your personal information to anyone else. Check out the FindStr utility in Chapter 4 and
you’ll discover the high-speed search mechanism used by people in the know. The FindStr utility
is but one of hundreds of commands and utilities discussed in this book. Just think about what you
can do with all of those free resources! Not only will you accomplish your work faster and with
fewer errors, but by reading this book, you can save your company a significant investment in
third party products that might not do the job anyway.
No other book has the level of detail provided by

Windows Administration at the Command
Line

. I scoured the Internet looking for all of the details about every Windows command and
utility I could find. In some cases, the information you see in this book appears nowhere else.
Much of the extra information in this book is the result of 20 years of hard won experience at the
command line starting with DOS and moving through the current version of Windows. This
book gives you the benefit of experience of many network administrators as told on their Web
sites and through correspondence in email.


10002.book Page xxi Friday, March 10, 2006 1:25 PM

xxii

INTRODUCTION



This book offers something for everyone. Everyone needs to locate files on their hard drive. If you
think the GUI is going to help you, think again. After a few frustrating searches, you’ll wish for a better
tool and you already have it in the form of the

Dir

command. Unlike the Windows GUI, the

Dir

com-
mand actually locates the files you request on the hard drive. The interesting thing is that the

Dir

command is very easy to use. Anyone can employ this command with very little training.
In fact, I included Chapter 1 of this book for those who have little or no experience with the com-
mand line. Chapter 1 helps you discover techniques for using the command line effectively and con-
figuring it to meet your specific needs. Even if you’re a complete command line novice, you can use
this book to get started by reading Chapter 1 first and becoming familiar with the command line.

Goals for Writing This Book


My initial goal for writing this book was to overcome the frustration of using the command line. I con-
stantly had to look up commands on the Internet because I couldn’t find a single resource that answered
all of my command line questions. After performing some research online, I found that many other
developers, administrators, and even average users were just as frustrated as I was. Consequently, writ-
ing a book about the command line seemed like an ideal way to help everyone. This book is the result.
Never again will you spend hours looking for the right answer to a command line question; you’ll find
them here.
Of course, documenting the command or utility usually isn’t enough. It’s important to know all
of the caveats of using the command or utility and answer questions such as how much damage it
could cause to a system. In many cases, you also need additional common information, such as a
cultural identifier. Consequently, as I wrote the book, I tried to provide as many tidbits of addi-
tional information as I could. These tidbits turn the documentation entries from functional into
truly useful.
You’ll also find a wealth of Real World Scenarios in this book. Each of the Real World Scenarios
tells you about the commands or utilities in general from a real world perspective. All of the stories
in these sections are real. Some of them did happen to me; many others didn’t. I did change the
names of those involved to protect the innocent. The point of all these Real World Scenarios is to
provide you something that simple documentation can’t: a perspective of why you should care
about a command or utility and how you can use it safely.
Along with all of the other documentation, I wanted to share a few of my favorite techniques for
working at the command line. You’ll find scripts that I have used for many years in this book to per-
form work at the command line. The batch files and scripts have seen real world use and you can
use them too. Copy the scripts or batch files out of the book and use them as is, or modify them to
meet your specific needs.

Who Should Read This Book?

Anyone can read this book. In fact, the first five chapters of the book are useful for anyone who uses
Windows regardless of experience level. The amazing array of commands that Windows hides at

the command prompt will give you the tools you require to get more work done with a lot less
effort. Gone are the frustrations of using graphical tools that simply don’t work most of the time.
I did anticipate a certain level of knowledge for even the novice command line user. You should
have a good idea of how to work with Windows. For example, you might want to think twice about
using the commands in this book if you don’t know how to perform a search of the hard drive using
Windows. In addition, you should be familiar with the mouse and relatively well acquainted with
the keyboard. This book doesn’t teach Windows basics—it goes right to the command line and

10002.book Page xxii Friday, March 10, 2006 1:25 PM

CONVENTIONS USED IN THIS BOOK

xxiii

helps you to start working there immediately. However, some command line information might
not make as much sense if you don’t already have at least some Windows experience.
Starting with Chapter 6 and moving on to Chapter 17, this book is targeted toward the needs of
developers and administrators. The average user will never require the commands listed in Chap-
ter 6. In fact, developers and administrators will use them only on occasion. These powerful com-
mands help you perform tasks that you generally can’t perform using the GUI. In fact, you’ll even
find a section that describes a technique for accessing Microsoft’s secret functions within the Win-
dows DLLs. See the “Accessing Functions within DLLs” section of Chapter 6 for details.
Developers and administrators also need to automate tasks in today’s hectic IT environment.
Chapters 7 through 11 help you get the most out of Windows automation features, which are actu-
ally quite formidable once you know how to use them. Should Windows fail to provide some func-
tionality, Chapters 12 through 14 provide tips and hints on third party applications you might want
to use. Chapters 15 through 17 provide an all-important view of the .NET Framework. Did you
know that you can compile JScript using the .NET Framework? Most people don’t know about this
feature because Microsoft hasn’t advertised it. Without spending a single penny, you can create
your own JScript executable that can take full advantage of the .NET Framework. Check out this

technique in the “Understanding the JSC Compiler Supplied with .NET” section of Chapter 14.
Everyone who wants to know the future will want to take a look at Chapters 18 and 19. These
two chapters provide a preview of what Vista will look like at the command line. All I can say after
working with Vista and Monad for a while is wow! What you’ll see in this chapter is going to amaze
you. Vista and Monad represent a significant and long anticipated departure from the command
line of the past. Yes, you can still use all of the older techniques in this operating system, but the new
features are going to amaze you with their ability to get work done quickly, efficiently, and with
fewer potential security issues. You get all this and better documentation besides. Monad is a fully
extensible command line shell, very much in the same vein as Unix shells, only a lot more powerful.

Conventions Used in This Book

It always helps to know what the special text means in a book. The following table provides a list
of standard usage conventions. These conventions make it easier for you to understand what a par-
ticular text element means.

Table 1.1:

Standard Usage Conventions

Convention
Explanation

Inline Code

Some code will appear in the text of the book to help explain application
functionality. The code appears in a special font that makes it easy to see. This
monospaced font also makes the code easier to read.

Inline Variable


As with source code, variable source code information that appears inline will also
appear in a special font that makes it stand out from the rest of the text. When you
see monospaced text in an italic typeface, you can be sure it’s a variable of some type.
Replace this variable with a specific value. The text will always provide examples of
specific values that you might use.

10002.book Page xxiii Friday, March 10, 2006 1:25 PM

×