Preuzmite Windows 7 Command Guide i više Rezime u PDF od Informatika samo na Docsity!
What Do You Want to Do?
I want to:
Windows 7 Portable Command Guide:
MCTS 70-680, and MCITP 70-685 and 70-
Darril Gibson Copyright © 2011 by Pearson Education, Inc. All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. ISBN-13: 978-0-7897-4735- ISBN-10: 0-7897-4735- Library of Congress Cataloging-in-Publication data is on file. Printed in the United States of America First Printing: March 2011
Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Pearson IT Certification cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
Bulk Sales Pearson IT Certification offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382- [email protected] For sales outside the United States, please contact International Sales [email protected]
Publisher Paul Boger Associate Publisher Dave Dusthimer Acquisitions Editor Betsy Brown Development Editor Andrew Cupp Series Editor Scott Empson Managing Editor Sandra Schroeder Senior Project Editor Tonya Simpson Copy Editor Bill McManus Proofreader The Wordsmithery LLC Technical Editor Chris Crayton Publishing Coordinator Vanessa Evans Book Designer Gary Adair Composition Studio Galou, LLC
iii
v
vi Contents
Contents ix
Contents xi
- Add drivers to a WinPE image Topic Chapter Page
- Add drivers to offline images
- Add features to offline images
- Append an image to a .wim file
- Capture a Windows 7 image
- Capture user state data
- Check and repair core operating system files
- Check and repair disk integrity
- Check connectivity with computers
- Check local and remote system security
- Configure a proxy server with netsh
- Configure a system for remote management
- Configure PowerShell to run scripts
- Convert a disk to NTFS
- Copy permissions when copying files
- Copy text to and from the Command Prompt window
- Create a batch file with Notepad
- Create a bootable VHD file
- Create a hard-link migration store
- Create a list of domain computers
- Create a message box
- Create a system repair disc
- Create and save a PowerShell script in the ISE
- Deploy a Windows 7 image
- Determine whether a file exists
- Disable driver signing checks
- Drag a path from Windows Explorer to the command prompt
- Flush the DNS cache
- Flush the DNS cache with a PowerShell script
- Identify which drivers are signed
- Log an event to an event log
- Manipulate power settings
- Manipulate which processes start on bootup
- Map a drive to a UNC path
- Introduction Contents at a Glance
- ChAPTEr 1 Launching and Using the Command Prompt PArT I : Command Prompt Basics
- ChAPTEr 2 Basic Rules When Using the Command Prompt
- ChAPTEr 3 Using Basic Commands
- ChAPTEr 4 Manipulating Files and Folders PArT II : Working with Files, Folders, and Disks
- ChAPTEr 5 Manipulating Disks
- ChAPTEr 6 Creating Batch Files PArT III : Scripting with Batch Files
- ChAPTEr 7 Scheduling Batch Files
- PArT IV : Managing and Maintaining Windows
- ChAPTEr 8 Using Windows 7 Maintenance Tools
- ChAPTEr 9 Retrieving Information About Windows
- ChAPTEr 10 Managing Security in Windows
- ChAPTEr 11 Configuring Windows 7 with netsh
- PArT V : Troubleshooting Windows
- ChAPTEr 12 Configuring Windows 7 Using Basic Troubleshooting Tools
- ChAPTEr 13 Troubleshooting Network Issues
- ChAPTEr 14 Using Recovery Tools
- ChAPTEr 15 Managing Remote Windows 7 Systems PArT VI : remote Administration
- ChAPTEr 16 Windows Management Instrumentation Command Line
- INTRODUCTION Table of Contents
- CHAPTER 1 Launching and Using the Command Prompt PArT I : Command Prompt Basics
- Launching the Command Prompt
- Pinning the Command Prompt to the Start Menu and the Taskbar
- Launching the Command Prompt with Elevated Privileges
- Responding to the UAC Prompt
- Using the Built-in Doskey Program
- Creating Mini Macros in Doskey
- Copying from and Pasting into the Command Prompt
- Copy from the Command Prompt Window
- Paste Text into the Command Prompt Window
- Changing the Options and Display of the Command Prompt
- CHAPTER 2 Basic Rules When Using the Command Prompt
- Using Uppercase or Lowercase
- Using Quotes to Enclose Spaces
- Understanding Variables
- Understanding Switches
- Understanding Wildcards
- Getting Help
- CHAPTER 3 Using Basic Commands
- Understanding Folders and Directories
- Understanding Paths
- Viewing Files and Folders with dir
- Changing the Path with cd
- Using Drag and Drop to the Command Prompt Window
- Deleting Folders with rd
- Creating Folders with md
- Controlling Output with more
- Redirecting Output
- Using the Redirect Symbol (>)
- Using clip
- Using exit
- CHAPTER 4 Manipulating Files and Folders PArT II : Working with Files, Folders, and Disks
- Associating File Extensions with assoc and ftype
- assoc
- ftype
- Viewing Attributes with attrib
- Compressing Files with compact
- Encrypting Files with cipher
- Copying Files with copy , xcopy , and robocopy
- copy
- xcopy
- robocopy
- Deleting or Removing Files with del
- Expanding Cabinet Files with expand
- Taking Ownership of Files with takeown
- Removing the Windows.old Folder
- Mapping Drives with net use
- CHAPTER 5 Manipulating Disks
- Manipulating and Viewing Disks with diskpart
- Creating a VHD File with diskpart
- Modifying the BCD Store for the VHD File
- Defragmenting Volumes with defrag
- Converting to NTFS with convert
- Managing the File System with fsutil
- CHAPTER 6 Creating Batch Files PArT III : Scripting with Batch Files
- Using Notepad
- Giving Feedback with echo
- Using Parameters
- Calling Another Batch File with call
- Clearing the Screen with cls
- Changing the Order of Processing with goto
- Checking Conditions with if
- Logging Events with eventcreate
- Looping Through Tasks with for
- Creating a Menu File Contents vii
- Documenting the Script with rem
- Pausing for the User
- Giving Users a Choice
- Creating the Batch File
- CHAPTER 7 Scheduling Batch Files
- Scheduling Batch Files with Task Scheduler
- Scheduling Tasks from the Command Line
- Creating a Scheduled Task with schtasks
- Creating a Scheduled Task from an XML File with schtasks
- Deleting a Scheduled Task with schtasks
- Viewing Scheduled Tasks with schtasks
- Changing Scheduled Tasks with schtasks
- Running and Ending Scheduled Tasks with schtasks
- PArT IV : Managing and Maintaining Windows
- CHAPTER 8 Using Windows 7 Maintenance Tools
- Controlling Power Settings with powercfg
- Query the Power Settings with powercfg
- Modify the Power Settings with powercfg
- Analyze the Power Settings with powercfg
- Checking Memory with mdsched
- Manipulating Services with sc
- Collecting Events with wecutil
- Restarting Systems with shutdown
- Launching Control Panel Applets from the Command Line
- CHAPTER 9 Retrieving Information About Windows
- Viewing System Information with systeminfo
- Viewing User Information with whoami
- Launching System Configuration with msconfig
- CHAPTER 10 Managing Security in Windows
- Manipulating Credentials with cmdkey
- Installing Updates with wusa
- Installing Applications with msiexec
- Auditing Systems with mbsacli
- CHAPTER 11 Configuring Windows 7 with netsh viii Contents
- Understanding netsh
- Understanding Contexts
- Configuring a Proxy Server
- Configuring the Network Interface with netsh
- PArT V : Troubleshooting Windows
- CHAPTER 12 Configuring Windows 7 Using Basic Troubleshooting Tools
- Identifying the System Name with hostname
- Verifying Core System Files with sfc
- Checking Digital Signatures with sigverif
- Viewing Active Tasks with tasklist
- Terminating Processes with taskkill
- Viewing Installed Drivers with driverquery
- CHAPTER 13 Troubleshooting Network Issues
- Viewing and Manipulating TCP/IP Configuration with ipconfig
- Viewing the Physical Address with getmac
- Checking Connectivity with ping
- Viewing the Router Path with tracert
- Checking for Data Loss with pathping
- Checking for Records in DNS with nslookup
- CHAPTER 14 Using Recovery Tools
- Manipulating the Boot Process with bcdedi t
- Commands That Operate on a Store
- Commands That Control Output
- Commands That Control the Boot Manager
- Commands That Operate on Entries in the Store
- Commands That Operate on Entry Options
- Disable Driver Signing
- Creating a System Repair Disc with recdisc
- Checking and Repairing Disks with chkdsk
- Repairing BitLocker Drives with repair-bde
- CHAPTER 15 Managing Remote Windows 7 Systems PArT VI : remote Administration
- Configuring Windows 7 for Remote Administration
- (RDC) Configuring System for Remote Desktop Connection
- Configuring System for Remote Access Using an MMC
- Connecting to Remote Systems with mstsc
- Configuring Windows Remote Management with winrm
- Executing Commands Remotely with winrs
- CHAPTER 16 Windows Management Instrumentation Command Line
- Understanding wmic
- Configuring the Firewall to Allow wmic
- Running wmic
- Modifying the Format with the /format Switch
- Retrieving Help from wmic
- Understanding Aliases
- Operating System Aliases
- Disk Drive Aliases
- System Hardware Aliases
- User, Group, and Domain Aliases
- Using Verbs
- CHAPTER 17 Understanding Images PArT VII : Creating and Managing Images
- Understanding WIM Files
- Using Windows Deployment Services and Images
- Comparing Boot and Install Images
- Comparing Thick and Thin Images
- CHAPTER 18 Preparing a System to Be Imaged with Sysprep
- Understanding Sysprep
- Running the Sysprep GUI
- Running sysprep from the Command Line
- CHAPTER 19 Installing the Windows Automated Installation Kit x Contents
- Downloading the WAIK
- Installing the WAIK
- Viewing the WAIK Tools
- CHAPTER 20 Using imagex
- Creating WinPE on a Bootable USB
- Capturing Images with imagex
- Appending Images with imagex
- Deleting Images with imagex
- Deploying Images with imagex
- (DISM) Tool CHAPTER 21 Using the Deployment Image Service and Management
- Online Servicing Versus Offline Servicing
- Mounting Images
- Getting Information About Mounted Images
- Modifying Images
- Working with Drivers
- Working with Packages and Features
- Miscellaneous Image Modifications
- Saving Images
- CHAPTER 22 WinPE Commands PArT VIII : Working with WinPE and Setup
- Add Drivers to WinPE with drvload
- Run Commands Within WinPE with wpeutil
- CHAPTER 23 Installing Windows 7 with setup
- Installing Windows 7 with setup
- Using the Autounattend.xml File
- Using slmgr
- Basic slmgr Commands
- slmgr Activation Commands
- slmgr Commands Used for KMS Clients
- slmgr Commands Used for Token-Based Activation
- CHAPTER 24 Capturing User Data with scanstate PArT IX : Migrating User Data with USMT
- Understanding Migration Stores
- Reviewing Migration Paths
- Understanding Hard-Link Migration Stores
- Capturing Migration Data with scanstate
- Specifying XML Files
- Modifying XML Files
- Identifying Users to Migrate with scanstate
- Encrypting the Migration Store with scanstate
- Simple Error Handling with scanstate
- Handling EFS Files
- Migrating Data from the Windows.old Folder
- CHAPTER 25 Restoring User Data with loadstate
- Running loadstate
- Specifying XML Files
- Specifying Hard-Link Options
- Deleting the Hard-Link Store
- Identifying Users to Migrate
- Decrypting an Encrypted Migration Store
- Handling Errors
- CHAPTER 26 Understanding PowerShell Commands PArT X : Using PowerShell
- Launching PowerShell
- Understanding PowerShell Verbs and Nouns
- Tabbing Through PowerShell Commands
- Understanding the Different Types of PowerShell Commands
- Creating Aliases
- Discovering Windows PowerShell Commands
- Exploring get-member
- Redirecting Output with Windows PowerShell
- Understanding PowerShell Errors
- Understanding PowerShell Variables
- Using Comparison Operators
- Understanding Pipelining
- CHAPTER 27 Using the Integrated Scripting Environment (ISE) xii Contents
- Launching the ISE
- Exploring the ISE
- Executing Commands in the ISE
- Creating and Saving a Script in the ISE
- CHAPTER 28 Creating and Running PowerShell Scripts
- Setting the Security Context
- Creating a PowerShell Profile
- Creating and Modifying the Global PowerShell Profile
- Running PowerShell Scripts
- Flushing the DNS Cache
- Creating a List of Domain Computers
- Logging Processes with a get-process Script
- Testing for the Existence of a File
- Creating Output as HTML
- Running a Script Against Multiple Computers
- Creating a PowerShell Message Box
- Scheduling PowerShell Scripts
- CHAPTER 29 Group Policy Overview PArT XI : Group Policy and the Command Line
- Understanding Group Policy Settings
- Blocking Inheritance
- Enforcing GPOs
- Using Loopback Processing
- Running Scripts with Group Policy
- Running PowerShell Scripts via Group Policy
- CHAPTER 30 Group Policy Command-Line Tools
- Viewing Group Policy Settings with gpresult
- Refreshing Group Policy Settings with gpupdate
- APPENDIx A Create Your Own Journal Here
xiv About the Series Editor
About the Series Editor
Scott Empson is the associate chair of the Bachelor of Applied Information Systems Technology degree program at the Northern Alberta Institute of Technology in Edmonton, Alberta, Canada, where he teaches Cisco routing, switching, and network design courses. Scott is also the program coordinator of the Cisco Networking Academy Program at NAIT, a Regional Academy covering Central and Northern Alberta. He has earned three undergraduate degrees: a Bachelor of Arts, with a major in English; a Bachelor of Education, again with a major in English/Language Arts; and a Bachelor of Applied Information Systems Technology, with a major in Network Management. Scott also has a Masters of Education degree from the University of Portland. He holds several industry certifications, including CCNP, CCAI, Network+, and C|EH.
Scott is the series creator and one of the authors of the Portable Command Guide Series. Portable Command Guides are filled with valuable, easy-to-access information to quick- ly refresh your memory. Each guide is portable enough for use whether you’re in the server room or the equipment closet.
About the Technical Editor
Christopher A. Crayton is an author, technical editor, technical consultant, security consultant, trainer, and SkillsUSA state-level technology competition judge. Formerly, he worked as a computer and networking instructor at Keiser College (2001 Teacher of the Year); as network administrator for Protocol, a global electronic customer relation- ship management (eCRM) company; and at Eastman Kodak headquarters as a computer and network specialist. Chris has authored several print and online books, including The A+ Exams Guide , Second Edition (Cengage Learning, 2008), Microsoft Windows Vista 70-620 Exam Guide Short Cut (O’Reilly, 2007), CompTIA A+ Essentials 220- Exam Guide Short Cut (O’Reilly, 2007), The A+ Exams Guide , The A+ Certification and PC Repair Handbook (Charles River Media, 2005), The Security+ Exam Guide (Charles River Media, 2003), and A+ Adaptive Exams (Charles River Media, 2002). He is also co-author of How to Cheat at Securing Your Network (Syngress, 2007). As an experienced technical editor, Chris has provided many technical edits/reviews for sev- eral major publishing companies, including Pearson Education, McGraw-Hill, Cengage Learning, Wiley, O’Reilly, Syngress, and Apress. He holds MCSE, A+, and Network+ certifications.
We Want to Hear from You! xv
We Want to Hear from You! As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way. As an associate publisher for Pearson IT Certification, I welcome your comments. You can email or write me directly to let me know what you did or didn’t like about this book—as well as what we can do to make our books better. Please note that I cannot help you with technical problems related to the topic of this book. We do have a User Services group, however, where I will forward specific technical questions related to the book. When you write, please be sure to include this book’s title and author as well as your name, email address, and phone number. I will carefully review your comments and share them with the author and editors who worked on the book. Email: [email protected] Mail: David Dusthimer Associate Publisher Pearson IT Certification 800 East 96th Street Indianapolis, IN 46240 USA
Reader Services Visit our website and register this book at pearsonitcertification.com for convenient access to any updates, downloads, or errata that might be available for this book.
Introduction
Thanks for buying Windows 7 Portable Command Guide. I’d love to say that this book was my idea, but the real credit goes to Scott Empson, who originally developed the vision of this book with Cisco certifications. I’ve worked with Scott and Pearson Publishing to help bring the same type of books he created for Cisco products to profes- sionals working on Microsoft products. Scott’s vision started with the idea that many IT professionals who have already learned the theory still sometimes need help remember- ing how to implement it.
The book doesn’t go into depth teaching these concepts. The idea is that you already understand them. Instead, the goal is to provide enough information to help you remember what you can do and how to do it in a small, portable, and useful journal, not an encyclopedic-sized volume. However, even if a concept is new to you, there’s enough information for you to start typing at the command prompt to gain a better understanding.
As an example, you probably know that you can refresh Group Policy from the com- mand prompt, but you might not always remember the exact command is gpupdate / force. You might remember that sysprep is used to prepare a computer for imaging, but you might not always remember that the full command is sysprep /oobe /generalize. In other words, you know the theory behind why you’d update Group Policy, and why you’d run sysprep, but you might not always remember the syntax. This book is a ready reference of useful commands and procedures with clear-cut examples. It shows the exact syntax of many of the commands needed for administrative tasks performed regu- larly by Windows 7 administrators.
I started the outline of this book by ensuring that command-prompt commands covered by the Microsoft Certified Information Technology Professional (MCITP) certifica- tions on Windows 7 were included. This includes the 70-680 and 70-685 exams for the MCITP: Enterprise Desktop Support Technician 7 certification, and the 70-680 and 70-686 exams for the MCITP: Enterprise Desktop Administrator 7 certification. I then added the commands I’ve found valuable in my day-to-day work on networks and from classroom teaching.
Many IT professionals use an engineering journal to help them remember key informa- tion needed on the job. It might include specific commands that they sometimes forget, IP addressing schemes used on their networks, steps for important maintenance tasks that are performed infrequently, or anything else they want to easily recall by looking at
2 Command Syntax Conventions
the journal. If you already have an engineering journal of your own, you can add this as a Windows 7 addendum. If you don’t have one, you can start with this book. It includes the same “Create Your Own Journal Here” appendix that Scott uses in the Cisco series. These are blank pages you can use to add your own notes and make this your journal, not mine.
Command Syntax Conventions
The conventions used to present command syntax in this book are as follows:
n (^) Boldface indicates syntax that is entered literally as shown. n (^) Italic indicates syntax for which you supply actual values. n (^) Vertical bars (|) separate alternative, mutually exclusive choices. n (^) Square brackets ([ ]) indicate an optional element. n (^) Braces ({ }) indicate a required choice.