Windows
7
Portable Command
Guide:
MOTS
70-680,
and MCITP 70-685
and 70-686
Darril Gibson
800 East 96th Street
INTRODUCTION 1
PART I:Command PromptBasics
CHAPTER 1
Launching
andUsing
the CommandPrompt 3 Launchingthe CommandPrompt
3Pinning
the CommandPrompt
to the StartMenu and theTaskbarLaunching
the CommandPrompt
with ElevatedPrivileges
4 Respondingtothe UACPrompt
5Usingthe Built-inDoskey
Program
7Creating
Mini Macros inDoskey
9Copyingfrom andPastinginto the CommandPrompt 9
Copy
from the CommandPrompt
Window 10 Paste Textintothe CommandPromptWindow 10Changing
theOptions andDisplay
oftheCommand Prompt 11CHAPTER 2 Basic Rules When
Using
the CommandPrompt
15 Using UppercaseorLowercase 15Using
QuotestoEncloseSpaces
16Understanding Variables 17
Understanding Switches 18
Understanding
Wildcards 18Getting
Help 19CHAPTER3
Using
Basic Commands 27Understanding Folders and Directories 27
Understanding Paths 28
ViewingFiles and Folders withdir 30 Changingthe Path with cd 31
Using DragandDropto theCommand
Prompt
Window 32 DeletingFolders with rd 33CreatingFolders with md 33
Controlling Output
with more 34Redirecting Output 35
Usingthe RedirectSymbol(>) 35
Using clip 35
vi Contents
PARTII:Workingwith
Files,
Folders,and DisksCHAPTER 4 Manipulating Files and Folders 37
AssociatingFileExtensions withassocandftype 37 assoc 39
ftype 39
ViewingAttributes with attrib 4 i
Compressing
Files withcompact 43Encrypting
Files withcipher
44Copying
Files with copy, xcopy, androbocopy 46copy 46
xcopy 47
robocopy
48Deleting
orRemoving
Files withdel 50ExpandingCabinet Fileswithexpand 51
Taking Ownership
of Files withtakeown 51Removing
the Windows.oldFolder 52MappingDrives withnetuse 53
CHAPTER5 Manipulating Disks 55
ManipulatingandViewingDisks withdiskpart 55 CreatingaVHD File with
diskpart
56 Modifyingthe BCDStore for the VHD File 57Defragmenting Volumes withdefrag 59 ConvertingtoNTFS with convert 61 Managingthe File Systemwith fsutil 62
PART III:
Scripting
withBatchFilesCHAPTER6
Creating
Batch Files 63Using
Notepad 63Giving
Feedback with echo 64 UsingParameters 65Calling
AnotherBatch File with call 68Clearing
the Screen with els 69Changingthe Order ofProcessingwith goto 69
Checking
Conditions with if 70Logging
Events with eventcreate 73Looping
ThroughTasks with for 75CreatingaMenu File 76
Documenting the
Script
with rem 76Pausing
fortheUser 77 GivingUsers a Choice 77Creating
the Batch File 78 CHAPTER7Scheduling
Batch Files 81Scheduling
Batch Files with Task Scheduler 81 SchedulingTasks from the Command Line 82Creating
aScheduled Task with schtasks 83Creating
aScheduledTask fromanXML File with schtasks 83Deleting
aScheduledTask with schtasks 85Viewing
Scheduled Tasks with schtasks 85Changing
Scheduled Tasks with schtasks 86Running
andEnding
ScheduledTasks with schtasks 87PART IV:Managing and
Maintaining
Windows 7CHAPTER8
Using
Windows 7 Maintenance Tools 89Controlling
PowerSettings
withpowercfg
89Query
the PowerSettings
withpowercfg 89Modify
the PowerSettingswithpowercfg
91Analyze
the PowerSettings
withpowercfg
93Checking Memory
with mdsched 93Manipulating
Services withsc 95CollectingEvents with wecutil 97
Restarting Systems
with shutdown 97LaunchingControl Panel Appletsfromthe Command Line 99
CHAPTER9 RetrievingInformation About Windows 7 103 Viewing
System
Information withsysteminfo 103 ViewingUser Information with whoami 106 Launching System Configurationwithmsconfig 107CHAPTER 10 Managing Securityin Windows7 111
ManipulatingCredentials withcmdkey 111
Installing Updates
withwusa 112Installing
Applications
with msiexec 115 Auditing Systemswith mbsacli 116viii Contents
CHAPTER11
Configuring
Windows 7 with netsh 121Understanding
netsh 121Understanding
Contexts 122 ConfiguringaProxy
Server 126Configuring
the Network Interfacewithnetsh 126 PART V:TroubleshootingWindows7CHAPTER 12 ConfiguringWindows 7Using BasicTroubleshootingTools 135
IdentifyingtheSystemNamewith hostname 135
VerifyingCoreSystemFiles with sfc 135
Checking Digital Signatureswithsigverif 137
ViewingActive Tasks with tasklist 138
TerminatingProcesses withtaskkill 142
ViewingInstalledDrivers with
driverquery
144CHAPTER 13 Troubleshooting Network Issues 145
Viewing
andManipulatingTCP/IPConfigurationwithipconfig 145Viewing thePhysicalAddress withgetmac 151
Checking Connectivitywithping 152
Viewingthe Router Path with tracert 155
Checkingfor Data Loss withpathping 155 Checkingfor Records inDNS withnslookup 156 CHAPTER14
Using Recovery
Tools 161Manipulating
the BootProcess with bcdcdit 161 Commands ThatOperateon aStore 165Commands That ControlOutput 166
Commands That Control the BootManager 167
Commands ThatOperateonEntries in the Store 169
Commands That
Operate
onEntry Options 170 Disable DriverSigning
170Creating
aSystem Repair
Discwithrecdisc 171CheckingandRepairingDisks with chkdsk 172 Repairing BitLocker Drives withrepair-bde 175
PART VI: Remote Administration
CHAPTER 15
Managing
Remote Windows 7Systems
177Configuring
Windows 7 for Remote Administration 177ConfiguringSystem forRemoteDesktopConnection (RDC) 177
Configuring System for Remote Access
Using
anMMC 180ConnectingtoRemoteSystemswith mstsc 181
ConfiguringWindows Remote Management with winrm 184 ExecutingCommandsRemotelywithwinrs 185
CHAPTER 16 Windows
Management
InstrumentationCommand Line 187Understanding
wmic 187ConfiguringtheFirewallto Allow wmic 188
Runningwmic 189
Modifying the Format with the/format Switch 191 Retrieving Helpfrom wmic 194
UnderstandingAliases 194
Operating
SystemAliases 196Disk Drive Aliases 197
System
Hardware Aliases 198User,Group,and Domain Aliases 200
UsingVerbs 200
PARTVII:
Creating
andManaging Images
CHAPTER 17
Understanding Images
203 UnderstandingWIM Files 203Using WindowsDeployment Services andImages 205
Comparing
Boot and Install Images 207Comparing
Thick and ThinImages 213CHAPTER 18
Preparing
aSystemto BeImaged
withSysprep
215Understanding
Sysprep
215 Runningthe SysprepGUI 216x Contents
CHAPTER 19
Installing
the Windows Automated Installation Kit 221Downloadingthe WAIK 221 Installingthe WAIK 221 Viewingthe WAIK Tools 224
CHAPTER20 Using imagex 227
CreatingWinPEon aBootable USB 227
Capturing
Imageswithimagex 231Appending
Imageswithimagex 233Deleting Images withimagex 235
Deploying
Images withimagex 235CHAPTER 21 UsingtheDeployment ImageService and
Management
(DISM)Tool 237OnlineServicingVersus Offline
Servicing
237 Mounting Images 238GettingInformationAbout Mounted
Images
240 Modifying Images 240Workingwith Drivers 241
WorkingwithPackagesandFeatures 242
MiscellaneousImageModifications 244 Saving Images 245
PART VIII: Workingwith WinPE and
Setup
CHAPTER 22 WinPE Commands 247
AddDriverstoWinPE with drvload 247
RunCommands Within WinPE with
wpeutil
248CHAPTER 23
Installing
Windows 7 with setup 251 InstallingWindows7with setup 251Using
the Autounattend.xml File 252Using slmgr
253Basic slmgr Commands 254 slmgrActivation Commands 255
slmgr
Commands Used for KMS Clients 256PARTIX: MigratingUser Data with USMT
CHAPTER 24
Capturing
User Data with scanstate 259Understanding Migration
Stores 259Reviewing Migration
Paths 259Understanding
Hard-LinkMigration
Stores 263 CapturingMigration
Data with scanstate 265Specifying
XML Files 266Modifying
XML Files 266Identifying
UserstoMigratewith scanstate 268Encrypting
theMigrationStore withscanstate 269Simple
Error Handlingwith scanstate 270Handling
EFS Files 270Migrating
Data from theWindows.old Folder 271 CHAPTER 25Restoring
User Data with loadstate 273Runningloadstate 273
Specifying
XML Files 274 SpecifyingHard-LinkOptions
275 Deletingthe Hard-LinkStore 275 IdentifyingUserstoMigrate
276Decryptingan
Encrypted Migration
Store 277 HandlingErrors 278PART X:UsingPowerSheH
CHAPTER 26
Understanding
PowerShellCommands 279Launching
PowerShell 279UnderstandingPowerShell Verbs andNouns 280
Tabbing
ThroughPowerShell Commands 284Understanding
the DifferentTypesof PowerShellCommands 285 CreatingAliases 286Discovering
Windows PowerShellCommands 286Exploring get-member
288Redirecting Output
with Windows PowerShell 291Understanding
PowerShell Errors 291Understanding
PowerShellVariables 293Using
Comparison Operators
295xii Contents
CHAPTER27
Using
theIntegrated Scripting
Environment(ISE)
299 Launching the ISE 299Exploring
the ISE 300ExecutingCommands in the ISE 302 Creatingand
Saving
aScript
in the ISE 303CHAPTER 28
Creating
andRunning
PowerShellScripts
309 Settingthe SecurityContext 309Creating
aPowerShell Profile 310CreatingandModifyingthe Global PowerShellProfile 312
RunningPowerShellScripts 313 FlushingtheDNS Cache 314
CreatingaListof DomainComputers 315 LoggingProcesses with aget-processScript 316 Testingfor the Existence ofaFile 318
Creating OutputasHTML 318
Runninga Script Against Multiple Computers 320 CreatingaPowerShellMessage Box 322 SchedulingPowerShell
Scripts
326PART XI:Group Policyand the Command Line
CHAPTER 29 Group PolicyOverview 329
Understanding Group Policy Settings 329
BlockingInheritance 333
Enforcing GPOs 334
Using Loopback Processing 335
Running Scripts
withGroup Policy 336Running
PowerShellScriptsviaGroup Policy 339CHAPTER 30 Group PolicyCommand-Line Tools 341 Viewing Group Policy Settingswithgpresult 341 Refreshing Group Policy Settingswithgpupdate 343 APPENDIXA Create Your Own JournalHere 347