order
The first part is to use Windows script host to write scripts.
Chapter 1 Windows Script Host (WSH) 1
1. 1 What is a Windows script 1?
1. 1. 1 "script" section 1
1. 1.2 Windows Part II
1. 1.3 "Host" Part II
What is the difference between 1. 1.4 and writing batch file 3?
1.2 scripting language 3
1.2. 1 VBScript4
1.2.2 JScript4
1.2.3 Perl4
1.2.4 Python5
1.2.5 Open the object REXX5
1.2.6 roubles 5
1.2.7 Select Language 5
1.3 A simple script 5
Script file of type 1.4 7
1.4. 1 JSE and VBE: coding script 8
1.4.2 Windows Script File (WSF)8
1.4.3 Windows Script Component 10
WSH settings 10
Create the first script file 10.
1.5. 1 Create a script folder and make it secure 10.
1.5.2 Create a script 12
1.5.3 script editing tool 12
1.6 How do Windows run scripts 13
1.6. 1 Wscript and Cscript 13
1.6.2 Script running mode 14
1.6.3 Pass the information to the script 15.
1.6.4 Save the result of the script 16.
1.6.5 Wscript and Cscript command options 17
1.7 Run your own script 19
1.7. 1 Add the script to the path 19.
1.7.2 Run the script 20 with the shortcut icon.
1.7.3 making script shortcuts 20
1.7.4 Run the script in batch file 2 1
1.7.5 Automatically run scripts 2 1
1.8 security issues
1.9 Debugging Script 23
Where can I get more information?
Chapter 2 VBScript tutorial 27
2. Introduction to1VBScript 27
2. 1. 1 variable 28
2. 1.2 constant 28
2. 1.3 Naming constant 29
2. 1.4 operator and expression 30
2. 1.5 Automatic type conversion 32
2.2 Process Control 32
2.2. 1 If … then statement 33
2.2.2 Selection of Case Statement 35
Do While loop 36
2.2.4 terminate the loop 38 with the outlet Do.
2.2.5 Calculate 39 with the next statement For… ...
2.2.6 Using For…Each to process sets and arrays 39
2.3 VBScript function 40
2.3. 1 Call function and subroutine 40
Documentation and Grammar 4 1
2.3.3 String operation function 42
Date and time function 45
2.4 Interaction with users 47
2.4. 1 MsgBox () function 48
InputBox () function 49
2.4.3 display simple text message 5 1 with Wscript. echo
2.5 advanced VBScript theme 52
2.5. 1 error handling 52
2.5.2 Process: Functions and Subroutines 53
Array 54
Variable range 56
2.6 How to further study 56
The third chapter object 57
3. 1 object introduction 57
3. 1. 1 Class and Example 58
3. 1.2 containers and assemblies 58
3. 1.3 object naming 59
3.2 using Object 60 in VBScript
3.2. 1 automation and documentation file 6 1
3.2.2 Differences between attributes and methods 6 1
3.2.3 Nested Objects 62
3.2.4 Release the object 63
Use kit 63
3.3 using Object 64 in JScript
3.3. 1 Case-sensitive 64
3.3.2 Use Kit 64
3.4 using object 65 through ActivePerl
3.4. 1 Running Perl Script in WSH 66
Perl object interface 66
Use kit 67
3.5 using object 68 through ActivePython
3.6 Using WScript Object 69
3.7 Finding and Using Abnormal Objects 72
Chapter 4 File and Registry Access 77
4. 1 Finish the actual work 77
4.2 Operating Files and Folders 77
4.2. 1 script. File system object 78
4.2.2 Operation file and path name 82
Scripting. Drive object 86
Scripting. Folder object 88
Scripting. File object 93
4.3 Reading and Writing Files 96
4.3. 1 Text Stream Object 97
4.3.2 Reading Text from File 99
4.3.3 Write the text to the file 100.
Use standard input and standard output 104
4.3.5 Reading binary file 106
4.4 read and write XML 1 10
4.4. Some basic knowledge of1XML11
4.4.2 Read the XML file 1 17.
4.4.3 Create an XML or HTML file 1 19.
4.5 Operating procedures and shortcuts 12 1
4.5. 1 WScript。 Shell object 122
4.5.2 Run the program 125.
4.5.3 Creating and Modifying Shortcuts 130
4.6 Operating Environment 132
4.6. 1 extracting environmental information
4.6.2 Management Environment Settings 134
4.7 Operation Registry 136
4. 7. 1 View registry keys and values 137
4.7.2 Save information in the registry 137.
Chapter 5 Network and Printer Objects 140
5. 1 Manage network and printer connection 140
5.2 Access to Network User Information 143
5.3 Managing Drive Mapping 145
5.3. 1 List drive mappings using EnumNetworkDrives 145.
5.3.2 Add drive mapping 147
5.3.3 Delete the driving diagram 148.
5.3.4 Set the mapping 149 in the script.
5.4 Managing network printer connections 150
5.4. 1 Display printer information 15 1.
5.4.2 Connect the network printer 152.
5.4.3 Redirect the DOS session printer 153
5.4.4 Delete the printer group 154
5.4.5 Set the default printer 155.
5.5 Print 156 from the script
Chapter 6 Message and Fax Objects 158
6. 1 Send e-mail from script using CDO 158
6.2 CDO object model 159
CDO。 Message object 16 1
6.2.2 Use the field 165.
6. 2. 3 CDO. message object field 167.
6.2.4 CDO Body Parts Kit 168
6.2.5 CDO body parts object 168
6.2.6 ADO stream object 17 1
CDO。 Configuration object 17 1
6.3 Sending messages with CDO 175
6.3. 1 build message 175
6.3.2 Add the annex 178.
6.3.3 HTML message containing image 179
6.3.4 Specify the recipient and the subject 180
6.3.5 Specify the sending server 180.
6.3.6 Send message 18 1
Comprehensive application of 6. 3. 7 182
6.4 Fax from script 186
6.4. 1 Sending a fax using a script 189
6.4.2 Get more information about fax 190.
Chapter VII WMI 192
7. Introduction to1WMI192
7. 1. 1 WMI function 193
7. 1.2 namespace 193
7. 1.3 Remote Management Window 195
7.2 WMI connection 197
7.2. 1 WMI object hierarchy 197
7.2.2 Connect 200 with WbemScripting. SWbemLocator object.
7.2.3 Connect 20 1
7.2.4 Connecting to the local computer 202
7.2.5 Security and Certification 202
7.2.6 Specify security options 205
7.3 WMI Collection and Query 206
7.3 1 swbemservices 207
7.3.2 WQL Query 208
SWbemObjectSet209
SWbemObject2 10
7. 3. 5 swbemethodset and SWBEMPropertySet211
7.4 scripting language 2 12
7.5 WMI Sample 2 13
Collecting system information 2 14
7.5.2 Managing printers 2 15
7.5.3 Monitoring Windows service packages and hot patches 2 15
7.5.4 Management Services and Tasks 2 16
7.6 Get more information218
Chapter 8 Active Directory Script Programming Interface 2 19
8. 1 Manage User Directory 2 19
Use 8.1.1adsi219.
8. 1.2 restrictions on the use of ADSI and WSH 220
8.2 ADSI concept 220
8.2. 1 Multiple Inheritance 222
Create ADSI object 223
Directory security 225
8.2.4 Determining the difference between the container and the blade 226
8.3 ADSI228 for WinNT: Provider
8.3. 1 IADs229
8.3.2 IADsCollection and iadcontainer 23 1
8.3.3 Operating ADSI device 232
8. 3. 4 iads Computer and iads Computer-Operation 233
IADsDomain235
IADsFileService and IADsFileService- operation 237
IADsFileShare239
8.3.8 IADsGroup240
8.3.9 IADsMembers24 1
8 . 3 . 10 iadsnamespaces 24 1
8.3.11iadspprintjob and iadspprintjob-operation 242
8.3.12 iadspntqueue and iadspntqueue-operation 244
Iads service and iads service-operation 246
8.3. 14
8.3. 15 IADsUser250
8.4 IIS and Exchange25 1
8.5 Managing Active Directory 252
8.6 Active Directory Object 254
8.6. 1 root 254
8.6.2 IADsO and IADsOU255
8.7 developing ADSI scripts 256
8.8 EzAD Scriptomatic257
8.9 Get more information 258
Chapter 9 is computer and network management deployment script 260.
9. 1 Using Scripts in the Real World 260
9.2 using WSF file 26 1
WSF file format reference 262
9.2.2 Using WSF file to provide online help 266
9.2.3 Handling command line parameters 267
9.2.4 contains multiple scripts 270.
Comprehensive application of 9. 2. 5 27 1
9.3 Deploying Scripts on the Network 274
9.4 Create a simple installer using IExpress 274
9.4. 1 Create an IExpress installation script or batch file 277
9.4.2 Handling User Account Control 278
9.4.3 provides an uninstall option 279.
9.5 Managing scripts for other computers 280
Remote scripting 282
9.5.2 Copying Scripts to Multiple Computers 282
9.6 Script Security Issues 284
9.6. 1 script signature 285
9.6.2 Script Encoder 288
9.7 Establishing Login Script 288
9.7. 1 User Profile Login Script 289
9.7.2 Scripts for login, logout and other events on Windows 7 and Vista 290.
9.7.3 Group Policy Login, Exit, Start and Close Scripts 290
9.8 Plan script automatically runs 29 1
9.8. 1 Writing unattended scripts 292
9.8.2 Send a message to the event log 293
9.8.3 Using Task Scheduler to Schedule Scripts 296
The second part of the command line environment
Chapter 65438 +00 CMD command line 299
10. 1 command prompt window 299
10.2 run CMD300.
10.2. 1 Open the command prompt 30 1 with administrator privileges.
10.2.2 CMD option 302
10.2.3 close command extension 303.
10.3 command line processing 303
Stop the runaway program 304
Console program input and output 304
10.3.3 using the console window 305
10.3.4 I/O redirection and pipeline 305
10.3.5 copy and paste 308 in the command prompt window.
10.3.6 command editing and history list 308
10.3.7 name auto-completion 309
10.3.8 Opening the directory name automatically completes 3 10
Multiple commands on the line of 10.3.9 3 1 1
10.3. 10 Use parentheses to combine the command 3 1 1.
10.3. 1 1 parameters, commas and quotation marks 3 12
10.3. 12 escape special character 3 12
10.4 configure CMD command 3 12
10.4. 1 automatic operation 3 12
10.4.2 environment variable replacement 3 13
10.4.3 Search Path 3 13
10.4.4 Predefined environment variables and virtual environment variables.
10.4.5 Set the default environment variable 3 16.
10.5 built-in command 3 17
10.5. 1 extended command 327
Use the dir command to list files 327.
10.5.3 use the set command to set the variable 330.
10.5.4 Conditional processing with if command 33 1
10.5.5 use the for command to scan the file 332.
10.6 Get more information 335
Chapter 1 1 Approval Document 337
1 1. 1 Why use batch file 337?
1 1.2 Creating and Using Batch Files 337
1 1.3 batch file programming 339
1 1.4 displays the information of the batch file 340.
1 1.5 parameter substitution 340
1 1.6 parameter editing 34 1
1 1.7 Conditional processing using if 343
1 1.7. 1 basic if command 343
1 1.7.2 View files and folders 343
1 1.7.3 Check whether a program is successful 343
1 1.7.4 Several commands after if 344 is executed.
1 1.7.5 extended test 345
1 1.8 processes multiple parameters 346.
1 1.9 Use environment variable 348
1 1. 10 uses the for command to process multiple items 349.
Multiple commands 350 are used in the for loop.
1 1. 10.2 delay spread 352
11.11using batch file subroutine 353
1 1. 12 hint 353.
1 1. 13 practical batch file technology50000.00000000015
1 1. 1 Handling command line options 354
1 1. 13.2 management network mapping 356
1 1. 13.3 Check whether the parameters are correct 357
1 1. 13.4 Save the log file 357
Chapter 12 MS-DOS program on Windows 359
12. 1MS-DOS program on Windows 359
12. 1. 1 virtual DOS machine 359
12. 1.2 MS-DOS and the command COM36 1
12.2 configure MS-DOS environment 36 1
Window and memory options 362
12.2.2 configuration. NT365
12.2.3 AUTOEXEC。 NT367
12.2.4 MS-DOS environment variable 367
12.3 MS-DOS and network 367
Print 368 from MS-DOS
12. 4. 1 print redirection 368
12.4.2 Print screen 369
12.5 configure serial communication with MS-DOS 369.
12.6 uses DOS 369 special equipment.
Managing MS-DOS programs 369
Chapter 13 Windows command line tool 37 1
13. 1 Windows command line program
13.2 required command line 37 1
13.3 GUI shortcut 372
13.4 Common Shell 374
13.4. 1
More 377
13
13.4.4
13.5 file management tool 380
13.5. 1 attribute 38 1
13
13.6 management ability tool 385
1 driver query 385
13.6.2
Task list 386
13.6.4 task
13.6.5 sc388
13.7 network tools 390
13.7. 1
65438+
13.7.3 network statistics 399
65438
13.7.5 Ping 402
13
13.8 Get more tools 404
Part iii Windows PowerShell
Chapter 14 Introduction to Windows PowerShell 405
14. 1 What is Windows PowerShell405?
An object-oriented command Shell405
14. 1.2 is based on. NET framework.
An extensible environment 408
14.2 get Windows PowerShell408.
14.3 PowerShell environment410
14.4 PowerShell command prompt 4 10
14. 4. 1 command line editor 4 1 1
14.4.2 copy and paste 4 12
14.4.3 Pause the output and stop the runaway program 4 12
14.4.4 command line syntax 4 12
14.5 cmdlets, objects and scripts 4 14
14.6 asking for help 4 16
14.7 complete command prompt 4 17
14.8 alias 4 17
How to get the alias list 4 18
14.8.2 How to define a new alias 4 18?
14.9 navigation directory and other locations 4 18
14. 10 PowerShell Security419
14.10.1PowerShell Script and User Account Control 4 19
14. 10.2 script execution strategy 420
14.11powershell configuration file 42 1
Chapter 15 PowerShell Programming 423
15.1windowspowershell programming language 423
15.2 Windows PowerShell syntax 423
15.3 Note 424
15.4 variables and types 424
15.4. 1 literal value 425
15.4.2 object methods and properties 426
The object builder 427
15.4.4 String Interpolation 427
15.4.5 Special characters 428
15.4.6 Here-String 428
15.4.7 Release variable 428
Predefined variable 429
15.4.9 array430
15.4. 10 constant 434
15.5 expression 434
1 compare array 435
15.5.2 string operator 437
15.5.3 (execute) operator 439
15.5.4 operator priority 439
15.5.5 assignment operator 440
15.5.6 report value 44 1
15.5.7 forced conversion 44 1
15.5.8 Quotation 442
15.5.9 hashtable 442
15.6 process control 444
15.6. 1 if444
15.6.2 while445
Do … and do … until 445.
15.6.4 for 445
15.6.5
15.6.6 switch 447
Break through 449
15.6.8 Continue 449
15.6.9 Block 450th
15.7 exception handling 450
15.7. 1 trap 450
15.7.2 Try/Capture/Final 45 1
15.7.3 throw 45 1
15.8 defines function 452.
15.8. 1 function parameter 452
15.8.2 Function scope 454
15.8.3 point source operator 454
Variable range 455
Pipeline functions and filters 456
15.8.6 Electroplating 457
15.9 use. NET API458。
15.9. 1 calls the static member function 458.
15.9.2 operation string 459
15.9.3 Operation Date and Time 460
15.9.4 conversion value 462
15.9.5 Mathematical Function 462
Chapter 16 Using PowerShell464
16.1powershell 464 in the real world.
16.2 command line technology 465
16.2. 1 generate object 465
16.2.2 filter 466
Take practical action
16.3 format Cmdlet output 468
16.4 manipulating files and folders 469
16. 4. 1 Check whether the file exists 473
Read text from file 473
16.4.3 writing text to file 474
Identify the file 474 according to its size
16.5 Create a useful script 475
16.5. 1, comment 475
16.5.2 command line processing 575
16.5.3 write module 476
Exception handling as an exit strategy 477
16.6 uses hash table 478.
16.7 PowerShell integrated scripting environment 479
16.7. 1 start PowerShell ISE479.
16.7.2 configure ISE480.
16.7.3 Creating and Editing Scripts 480
Run scripts in 16. 7. 4 ISE 48 1
16.7.5 Set breakpoint and go to 482.
16.7.6 Interactive checking and modifying variables 482
16.7.7 conditional breakpoint483
16.8 remote and background power supply enclosure 483
16.9 How to continue studying 483
appendix
Appendix A VBScript reference 485
Appendix B CMD and batch file language reference 495
Appendix c command line program reference 503