for Windows 8.1, Windows Server 2012, Windows Server 2012 R2
William Stanek
at a Glance
Introduction
Overview of the Windows Command Line
Getting the Most from the Command Line
Command-Line Scripting Essentials
Working with the Registry
Managing System Services
Restarting and Shutting Down Computers from the Command Line
Event Logging, Tracking, and Monitoring
Managing Processes and Maintaining Performance
Scheduling Tasks to Run Automatically
Configuring, Maintaining, and Troubleshooting TCP/IP Networking
Essential Command-Line Tools Reference
Book Details
Price
|
2.00 USD |
---|---|
Pages
| 342 p |
File Size
|
1,854 KB |
File Type
|
PDF format |
Published
| Stanek & Associates |
Copyright
| 2015 William Stanek |
William Stanek (http://www.williamstanek.com/) has more than 20 years of hands-on experience with advanced programming and development. He is a leading technology expert, an award-winning author, and a pretty-darn-good instructional trainer. Over the years, his practical advice has helped millions of programmers, developers, and network engineers all over the world. His current and books include Windows 8.1 Administration Pocket Consultants, Windows Server 2012 R2 Pocket Consultants and Windows Server 2012 R2 Inside Outs.
William has been involved in the commercial Internet community since 1991. His core business and technology experience comes from more than 11 years of military service. He has substantial experience in developing server technology, encryption, and Internet solutions. He has written many technical white papers and training courses on a wide variety of topics. He frequently serves as a subject matter expert and consultant.
William has an MS with distinction in information systems and a BS in computer science, magna cum laude. He is proud to have served in the Persian Gulf War as a combat crewmember on an electronic warfare aircraft. He flew on numerous combat missions into Iraq and was awarded nine medals for his wartime service, including one of the United States of America’s highest flying honors, the Air Force Distinguished Flying Cross. Currently, he resides in the Pacific Northwest with his wife and children.
William recently rediscovered his love of the great outdoors. When he’s not writing, he can be found hiking, biking, backpacking, traveling, or trekking in search of adventure with his family!
Find William on Twitter at www.twitter.com/WilliamStanek
and on Facebook at www.facebook.com/William.Stanek.Author.
Introduction
Windows Command Line: The Personal Trainer is the authoritative quick reference guide to Windows Command Line and is designed to be a key resource you turn to whenever you have questions about Windows Command Line. To this end, the book zeroes in on the key aspects of Windows Command Line that you'll use the most.
Inside this book’s pages, you'll find comprehensive overviews, step-by-step procedures, frequently used tasks, documented examples, and much more. One of the goals is to keep the content so concise that the book remains compact and easy to navigate while at the same time ensuring that the book is packed with as much information as possible—making it a valuable resource.
What’s This Book About?
In this book, I teach you how Windows Command Line features work, why they work the way they do, and how to use them to meet your needs. One of the goals is to keep the content so concise that the book remains compact and easy to navigate while ensuring that the book is packed with as much information as possible—making it a valuable resource. In addition, this book provides hands-on, tips, and best practices for working with Windows Command Line.
Table of Contents
Introduction ...................................................................................................................................... 16
What’s This Book About? .............................................................................................................. 16
What Do I Need to Know? ............................................................................................................ 16
How Is This Book Organized? ...................................................................................................... 17
What Conventions Are Used in This Book? ............................................................................... 17
Other Resources ............................................................................................................................... 17
Chapter 1. Overview of the Windows Command Line
Command Line Essentials ............................................................................................................... 21
Understanding the Windows Command Shell ....................................................................... 21
Understanding Windows PowerShell ...................................................................................... 27
Configuring Command-Line Properties ................................................................................... 29
Working with the Command History ...................................................................................... 31
Making Supplemental Components Available ............................................................................ 33
Using the Microsoft Remote Server Administration Tools for Windows 8.1 ................... 33
Registering the Remote Server Administration Tools Package ............................................ 34
Configuring and Selecting Remote Server Administration Tools ........................................ 35
Removing the Remote Server Administration Tools ............................................................. 35
Removing the Remote Server Administration Tools Package .............................................. 36
Chapter 2. Getting the Most from the Command Line
Managing Command Shell Startup ............................................................................................... 38
Working with the Command Path ................................................................................................ 41
Managing the Command Path ................................................................................................... 41
Managing File Extensions and File Associations ..................................................................... 43
Redirecting Standard Input, Output, and Error ......................................................................... 44
Redirecting Standard Output to Other Commands ............................................................... 46
Redirecting I/O to and from Files ............................................................................................. 47
Redirecting Standard Error ........................................................................................................ 48
Chaining and Grouping Commands ............................................................................................. 48
Using Chains of Commands ....................................................................................................... 50
Grouping Command Sequences ................................................................................................ 50
Chapter 3. Command-Line Scripting Essentials
Creating Command-Line Scripts ................................................................................................... 52
Common Statements and Commands for Scripts ....................................................................... 54
Clearing the Command-Shell Window .................................................................................... 55
Adding Comments to Scripts ..................................................................................................... 56
Managing Text Display and Command Echoing .................................................................... 57
Fine-Tuning Command Echo with @ ...................................................................................... 58
Setting the Console Window Title and Colors ....................................................................... 59
Passing Arguments to Scripts......................................................................................................... 62
Getting Acquainted with Variables ............................................................................................... 63
Using Variables in Scripts ............................................................................................................... 65
Naming Variables ........................................................................................................................ 65
Setting Variable Values .............................................................................................................. 66
Substituting Variable Values ..................................................................................................... 68
Localizing Variable Scope ........................................................................................................... 70
Using Mathematical Expressions ................................................................................................... 71
Working with Arithmetic and Assignment Operators .......................................................... 72
Understanding Operator Precedence ........................................................................................ 73
Simulating Exponents ................................................................................................................. 74
Command-Line Selection Statements .......................................................................................... 74
Using If .......................................................................................................................................... 75
Using If Not .................................................................................................................................. 76
Using If Defined and If Not Defined ........................................................................................ 77
Nesting Ifs ..................................................................................................................................... 77
Making Comparisons in If Statements ..................................................................................... 78
Command Line Iteration Statements ............................................................................................ 79
Iteration Essentials ....................................................................................................................... 79
Stepping Through a Series of Values ........................................................................................ 81
Iterating Through Groups of Files ............................................................................................ 82
Iterating Through Directories ................................................................................................... 84
Parsing File Content and Output .............................................................................................. 86
Creating Subroutines and Procedures .......................................................................................... 89
Using Subroutines ....................................................................................................................... 90
Using Procedures ......................................................................................................................... 92
Chapter 4. Working with the Registry
Understanding Registry Keys and Values .................................................................................... 94
Querying Registry Values ............................................................................................................... 97
Comparing Registry Keys ............................................................................................................... 98
Saving and Restoring Registry Keys ............................................................................................ 100
Adding Registry Keys .................................................................................................................... 101
Copying Registry Keys .................................................................................................................. 102
Deleting Registry Keys .................................................................................................................. 103
Exporting and Importing Registry Keys ..................................................................................... 104
Loading and Unloading Registry Keys ........................................................................................ 105
Chapter 5. Managing System Services
Viewing Configured Services........................................................................................................ 109
Starting, Stopping, and Pausing Services.................................................................................... 112
Configuring Service Startup ......................................................................................................... 113
Configuring Service Logon ........................................................................................................... 114
Configuring Service Recovery ....................................................................................................... 116
Chapter 6. Restarting and Shutting Down Computers from the Command Line
Managing Restart and Shutdown of Local Systems .................................................................. 121
Managing Restart and Shutdown of Remote Systems ............................................................. 122
Adding Shutdown or Restart Reasons and Comments ............................................................ 122
Chapter 7. Event Logging, Tracking, and Monitoring
Windows Event Logging ............................................................................................................... 129
Viewing and Filtering Event Logs ................................................................................................ 134
Viewing Events ........................................................................................................................... 134
Filtering Events .......................................................................................................................... 136
Writing Custom Events to the Event Logs ................................................................................ 139
Creating and Using Saved Queries .............................................................................................. 141
Monitoring Performance: The Essentials ................................................................................... 146
Understanding Performance Monitoring at the Command Line ....................................... 146
Tracking Performance Data ..................................................................................................... 149
Chapter 8. Managing Processes and Maintaining Performance
Managing Applications, Processes, and Performance ............................................................... 156
Understanding System and User Processes ........................................................................... 156
Examining Running Processes ................................................................................................. 158
Obtaining Detailed Information on Processes .................................................................. 159
Viewing the Relationship Between Running Processes and Services ............................. 161
Viewing Lists of DLLs Being Used by Processes .............................................................. 163
Filtering Task List Output ................................................................................................... 165
Monitoring System Resource Usage and Processes .............................................................. 168
Stopping Processes .................................................................................................................... 179
Detecting and Resolving Performance Issues Through Monitoring ...................................... 181
Monitoring Memory Paging and Paging to Disk .................................................................. 182
Monitoring Memory Usage and the Working Memory Set for Individual Processes ..... 184
Resolving Performance Bottlenecks ........................................................................................ 188
Chapter 9. Scheduling Tasks to Run Automatically
Scheduling Tasks on Local and Remote Systems ...................................................................... 193
Introducing Task Scheduling ................................................................................................... 194
Monitoring Scheduled Tasks ................................................................................................... 200
Scheduling Tasks with Task Scheduler ...................................................................................... 202
Creating Basic Tasks ................................................................................................................. 202
Creating Advanced Tasks ......................................................................................................... 206
Managing Task Properties........................................................................................................ 208
Enabling and Disabling Tasks .................................................................................................. 209
Copying Tasks to Other Computers....................................................................................... 209
Running Tasks Immediately .................................................................................................... 210
Removing Unwanted Tasks ..................................................................................................... 210
Scheduling Tasks with Schtasks .................................................................................................. 210
Creating Scheduled Tasks with Schtasks /Create ................................................................ 211
Creating Scheduled Tasks Triggered by Windows Events ................................................. 218
Changing Scheduled Tasks with Schtasks /Change ............................................................. 220
Querying for Configured Tasks with Schtasks /Query ....................................................... 224
Creating Tasks Using XML Configuration Files .................................................................. 225
Running Tasks Immediately with Schtasks /Run ................................................................ 230
Stopping Running Tasks with Schtasks /End ....................................................................... 230
Deleting Tasks with Schtasks /Delete .................................................................................... 231
Chapter 10. Configuring, Maintaining, and Troubleshooting TCP/IP Networking
Using the Network Services Shell ............................................................................................... 233
Working with Netsh Contexts ................................................................................................ 233
Working with Remote Computers .......................................................................................... 237
Working with Script Files ........................................................................................................ 239
Managing TCP/IP Settings ......................................................................................................... 240
Configuring IPv4........................................................................................................................ 241
Setting a Static IPv4 Address............................................................................................... 241
Setting a Dynamic IPv4 Address ......................................................................................... 243
Adding IPv4 Addresses and Gateways ............................................................................... 244
Setting DNS Servers to Use for IPv4 ................................................................................. 245
Specifying Additional DNS Servers to Use ....................................................................... 246
Deleting IPv4 Address Resolution Protocol Cache .......................................................... 247
Deleting TCP/IPv4 Settings ............................................................................................... 247
Configuring IPv6........................................................................................................................ 249
Setting IPv6 Addresses ......................................................................................................... 249
Setting DNS Servers to Use for IPv6 ................................................................................. 251
Deleting TCP/IPv6 Settings ............................................................................................... 253
Supporting TCP/IP Networking ................................................................................................ 253
Obtaining and Saving the TCP/IP Configuration ............................................................... 254
Examining IP Address and Interface Configurations ........................................................... 257
Working with TCP Internet Control and Error Messages ................................................. 259
Examining Fragmentation, Reassembly, and Error Details ................................................. 263
Examining Current TCP and UDP Connections ................................................................. 264
Working with TCP ............................................................................................................... 265
Working with UDP .............................................................................................................. 268
Troubleshooting TCP/IP Networking ...................................................................................... 269
Viewing Diagnostic Information ............................................................................................. 270
Diagnosing General Computer Configuration Issues ........................................................... 272
Diagnosing IP, DNS, and WINS Configuration Issues ................................................. 290
Appendix A. Essential Command-Line Tools Reference ........................................................ 295
About the Author .......................................................................................................................... 341
What Do I Need to Know?
To get practical and useful information into your hands without the clutter of a ton of background material, I had to assume several things. If you are reading this book, I hope that you have basic networking skills and a basic understanding of Windows. With this in mind, I don’t devote entire chapters to understanding Windows architecture, installing Windows, or Windows startup and shutdown. I also assume that you are fairly familiar with Windows commands and procedures as well as the Windows user interface. If you need help learning Windows basics, you should read the Windows documentation.
How Is This Book Organized?
Rome wasn’t built in a day, and this book wasn’t intended to be read in a day, a week, or even 21 days. Ideally, you’ll read this book at your own pace, a little each day, as you work your way through the features Windows Command Line has to offer.
Making this book easy to follow and understand was my number one goal. I really want anyone, skill level or work schedule aside, to be able to learn how to effectively use Windows Command Line.
To make the book easy to use, this book is organized into multiple chapters. The chapters are arranged in a logical order, taking you from the essential concepts you need to know to work with Windows Command Line to techniques for managing computers with scripts.
Windows Command Line: The Personal Trainer is designed to be used with Windows Command Line for Administration: The Personal Trainer. While this book focuses on core features, the latter book focuses using Windows Command Line to manage computers, networks, printers and Active Directory.