|
| Click 'Like' and get an additional Rs 5 discount! |
Written for system and network administrators, Windows Script Host includes authoritative coverage of the VBScript language essentials, including script structure and statements; detailed discussion of the object-oriented paradigm, how it is used in Windows system scripting, and how to emply COM objects; program guides that provide additional insight for those who are new to programming; and proven, ready-to-use scripting solutions, including sample logon and system management scripts. If you design or administer Windows NT/2000 networks, this is an essential resource to help you implement system scripting across your network. This comprehensive reference will help you: install system scripting components on your network; automate or simplify system management tasks, ranging from copying files to monitoring a set of enterprise servers; create your own COM objects in VBScript through the use of Windows Script Components; and get immediate results by employing proven sample scripts.
Written for system and network administrators, Windows Script Host includes authoritative coverage of the VBScript language essentials, including script structure and statements; detailed discussion of the object-oriented paradigm, how it is used in Windows system scripting, and how to emply COM objects; program guides that provide additional insight for those who are new to programming; and proven, ready-to-use scripting solutions, including sample logon and system management scripts. If you design or administer Windows NT/2000 networks, this is an essential resource to help you implement system scripting across your network. This comprehensive reference will help you: install system scripting components on your network; automate or simplify system management tasks, ranging from copying files to monitoring a set of enterprise servers; create your own COM objects in VBScript through the use of Windows Script Components; and get immediate results by employing proven sample scripts.
A Short History of Scripting
From their earliest days, operating systems have typically incorporated some sort of command shell or command interpreter. This shell allows an interactive user to enter text commands and see the results as textual output. Interaction with these shells always follows the same basic pattern:
1. The operating system prompts the user to enter a command.
2. The user types a line of text (the command) and presses Enter (or some other command termination key).
3. The operating system executes the command and (typically) displays the results of this processing.
By entering sequences of these simple commands, an operator can control all aspects of operating system and computer operation.
Operating system designers were quick to notice that many systemsrelated tasks involve the repeated execution of specific sequences of commands. To increase efficiency and reduce errors, a system was devised to allow these command sequences to be stored in a file ready for later execution. Upon demand, the operating system reads the file and executes the commands it contains. These simple command lists are called shell scripts, batch files, or batch jobs.
Batchfiles have been significantly enhanced over the years. One of the first enhancements was parameterization, which allows the batch file to be supplied with arguments when it is executed. In addition, various controlflow techniques were borrowed from traditional programming languages. Eventually, batch files reached the point where they could be considered simple programming languages in their own right.
This evolution, however, has led to some significant problems. For example, in my book, Windows NT Shell Scripting (by Macmillan Technical Publishing), I described Windows NT batch scripts in detail, including the many script enhancements provided in the Windows NT command shell (CMD.EXE). However, these batch scripts are (at best) awkward to use, and the syntax of the scripts is cumbersome. More importantly, batch scripts are unable to interact with Windows applications to any great extent, which excludes these scripts from many possible uses. Finally, the enhanced Windows NT batch scripts are not cross-platform, and they cannot be run on the Windows 9S and 98 platforms.
These shortcomings have led Microsoft to devise a new set of script technologies that build not upon traditional command-line concepts, but upon modern object-oriented software techniques. These new technologies, collectively referred to here as system scripting, are the subject of this book.
Who Should Read This Book
Virtually anyone who wishes to automate a repetitive or awkward operating system task will benefit from the information in this book. However, this book is aimed primarily at Windows 2000 and Windows NT professionals, systems administrators, and power users. Thus, most of the examples and sample scripts deal with system administration and management issues. However, the techniques presented all have much wider applicability, and there is really no limit to the uses for system scripts. To illustrate this, the final sample script in this book presents a simple interactive game.
One area that can be daunting to some potential users of system scripting is that, for the first time, the core of the script system is a true computer language. Previously, Windows NT batch files could be viewed as an extended form of a macro, and therefore, they were just a substitution for directly typing in commands. With system scripting this is no longer the case, which means that many users may be faced with the need to learn a full programming language for the first time.
To ease the trepidation this can cause, I have included in this book a set of sidebars under the heading "Program Guide," which are intended to guide the beginner into the world of software programming with as little pain as possible.
About ActiveX Scripting Technology
This book describes several new system scripting technologies that are available for the Windows 2000 and Windows NT operating systems (as well as Windows 95 and 98). These are:
The foundation for all of these new technologies is an architecture known as ActiveX Scripting. The ActiveX Scripting architecture, shown in Figure 1.1, provides a standard way to separate script hosts from script engines. The script engines provide the actual script language, whereas the hosts provide an interface between the language and whatever application or facility you plan to script. Because the ActiveX Scripting architecture provides a standard way to connect hosts to engines, any engine can run with any host. Thus, for example, if you obtain a Perl ActiveX Scripting engine and install it, all ActiveX Scripting hosts will automatically be able to execute Perl scripts.
Examples of ActiveX Scripting hosts include the popular Internet Explorer web browser, the Microsoft Internet Information Server web server, and the Windows Script Components and WSH technologies described in this book. Examples of ActiveX Scripting engines include the VBScript and JScript languages. There are also third party ActiveX Scripting engine versions of other popular languages, including Perl and Tcl.
This book covers only the VBScript language because this language is in many ways more approachable for newcomers to programming. In addition, the popularity of Visual Basic means that many people will already be familiar with the underlying syntax of VBScript, based as it is upon this language. However, if you prefer to use another language, then you are free to do so-that is one of the advantages of the ActiveX Scripting architecture. However, if you do use a language other than VBScript or JScript, you will have to ensure that the language engine is installed on all machines where your scripts are to be executed.
Organization of This Book
This book is divided into three parts and several appendices.
Part I, "WSH and the VBScript Language"
The first part of the book covers two topics: WSH and the VBScript language (with the exception of objects and classes, which are described in Part II, "Objects and Classes"). As such, the information in this part forms the foundation for using system-scripting technologies.
If you are already familiar with VBScript, you might wish to scan the information on WSH briefly and then skip ahead to Part 11. If you have not used VBScript before or if you are unfamiliar with computer programming, the material in Part I will provide you with all the core concepts needed to use the VBScript language effectively.
Part 11, "Objects and Classes"
Part 11 of the book covers objects and classes, and it explains the objectoriented paradigm and how this paradigm is used in system scripting. The focus of this part of the book is on the objects and features that are built-in to either WSH or VBScript. You will also find information here on how to construct your own "in-script" objects using VBScript.
Part 11 also shows how to use COM Objects. Many technologies and applications expose their functionality through COM Objects, and therefore, understanding how to access these objects is critical to using system scripting effectively.
Finally, Part II of the book also describes Windows Script Components, which is a technology that allows you to create your own COM Objects using VBScript. Windows Script Components provides an excellent way to break up large projects into smaller sub-projects and provides the foundations for dynamic script re-use.
Part III, "Sample Script Solutions"
Part III of the book builds upon the material in the earlier two parts to provide a library of complete, ready-to-use sample scripts. These scripts can be used "as-is" or as a starting point for a custom script project.
Part IV, "Appendices"
Finally, the appendices at the end of the book provide additional informa- tion that might be useful to system script authors.
Throughout this book, VBScript source code is shown in a monospace font using a mixed-case convention. However, the VBScript language is not casesensitive, and source code can be entered as desired. This may not be true of third party ActiveX Scripting languages-consult the specific language documentation for information on case sensitivity.
When describing VBScript and other syntax (instead of showing an example), items that must be entered exactly are shown in mixed case. Placeholders that must be replaced by appropriate values are shown in lower case italic. Optional items are shown in brackets, and vertical bar characters separate alternatives, where one item from a list must be selected. For example, the Do command syntax is: Do [While expression]
This example shows that the Do command can be optionally followed by a While clause, which consists of the keyword While followed by an expression.
Some sample scripts in the book are shown with accompanying line numbers. These line numbers are for reference purposes only-scripts do not include line numbers in the program text.
Before You Continue
Before continuing, you might want to take a few minutes to install the latest system scripting components on your computer. Appendix A provides details on where to obtain these components and how to install them. You might also want to look at Appendix B, which provides some links to additional scripting resources, tools, and technologies.
The information in this book is based upon versions 1.0 and 2.0 of Windows Scripting. The VBScript information is based upon version 5.0 of the VBScript engine. Refer to Appendix A for information on obtaining the most recent versions of all these components.
Written for system and network administrators, Windows Script Host includes authoritative coverage of the VBScript language essentials, including script structure and statements; detailed discussion of the object-oriented paradigm, how it is used in Windows system scripting, and how to emply COM objects; program guides that provide additional insight for those who are new to programming; and proven, ready-to-use scripting solutions, including sample logon and system management scripts. If you design or administer Windows NT/2000 networks, this is an essential resource to help you implement system scripting across your network. This comprehensive reference will help you: install system scripting components on your network; automate or simplify system management tasks, ranging from copying files to monitoring a set of enterprise servers; create your own COM objects in VBScript through the use of Windows Script Components; and get immediate results by employing proven sample scripts.
About Author:
Tim Hill is a software and OS developer with more than 20 years of experience in systems software and operating system architectures. He has designed several real-time operating systems, including RMOS and PKS, the latter of which has been used extensively in missioncritical embedded systems, including ATMs and banking automation systems. After developing millions of lines of system-critical code, Tim is convinced that the best way to develop software is to leave the bugs out. After a number of years of consulting on all aspects of Windows NT development and architectural issues, Tim has recently joined Microsoftg, where he is working on new systems based upon Windows NT technologies.
Tim is also the author of the best-selling Windows NT Shell Scripting (MTP, 1998), which has received critical acclaim from readers, as well as the press.
Special Features:
A Short History of Scripting
From their earliest days, operating systems have typically incorporated some sort of command shell or command interpreter. This shell allows an interactive user to enter text commands and see the results as textual output. Interaction with these shells always follows the same basic pattern:
1. The operating system prompts the user to enter a command.
2. The user types a line of text (the command) and presses Enter (or some other command termination key).
3. The operating system executes the command and (typically) displays the results of this processing.
By entering sequences of these simple commands, an operator can control all aspects of operating system and computer operation.
Operating system designers were quick to notice that many systemsrelated tasks involve the repeated execution of specific sequences of commands. To increase efficiency and reduce errors, a system was devised to allow these command sequences to be stored in a file ready for later execution. Upon demand, the operating system reads the file and executes the commands it contains. These simple command lists are called shell scripts, batch files, or batch jobs.
Batchfiles have been significantly enhanced over the years. One of the first enhancements was parameterization, which allows the batch file to be supplied with arguments when it is executed. In addition, various controlflow techniques were borrowed from traditional programming languages. Eventually, batch files reached the point where they could be considered simple programming languages in their own right.
This evolution, however, has led to some significant problems. For example, in my book, Windows NT Shell Scripting (by Macmillan Technical Publishing), I described Windows NT batch scripts in detail, including the many script enhancements provided in the Windows NT command shell (CMD.EXE). However, these batch scripts are (at best) awkward to use, and the syntax of the scripts is cumbersome. More importantly, batch scripts are unable to interact with Windows applications to any great extent, which excludes these scripts from many possible uses. Finally, the enhanced Windows NT batch scripts are not cross-platform, and they cannot be run on the Windows 9S and 98 platforms.
These shortcomings have led Microsoft to devise a new set of script technologies that build not upon traditional command-line concepts, but upon modern object-oriented software techniques. These new technologies, collectively referred to here as system scripting, are the subject of this book.
Who Should Read This Book
Virtually anyone who wishes to automate a repetitive or awkward operating system task will benefit from the information in this book. However, this book is aimed primarily at Windows 2000 and Windows NT professionals, systems administrators, and power users. Thus, most of the examples and sample scripts deal with system administration and management issues. However, the techniques presented all have much wider applicability, and there is really no limit to the uses for system scripts. To illustrate this, the final sample script in this book presents a simple interactive game.
One area that can be daunting to some potential users of system scripting is that, for the first time, the core of the script system is a true computer language. Previously, Windows NT batch files could be viewed as an extended form of a macro, and therefore, they were just a substitution for directly typing in commands. With system scripting this is no longer the case, which means that many users may be faced with the need to learn a full programming language for the first time.
To ease the trepidation this can cause, I have included in this book a set of sidebars under the heading "Program Guide," which are intended to guide the beginner into the world of software programming with as little pain as possible.
About ActiveX Scripting Technology
This book describes several new system scripting technologies that are available for the Windows 2000 and Windows NT operating systems (as well as Windows 95 and 98). These are:
The foundation for all of these new technologies is an architecture known as ActiveX Scripting. The ActiveX Scripting architecture, shown in Figure 1.1, provides a standard way to separate script hosts from script engines. The script engines provide the actual script language, whereas the hosts provide an interface between the language and whatever application or facility you plan to script. Because the ActiveX Scripting architecture provides a standard way to connect hosts to engines, any engine can run with any host. Thus, for example, if you obtain a Perl ActiveX Scripting engine and install it, all ActiveX Scripting hosts will automatically be able to execute Perl scripts.
Examples of ActiveX Scripting hosts include the popular Internet Explorer web browser, the Microsoft Internet Information Server web server, and the Windows Script Components and WSH technologies described in this book. Examples of ActiveX Scripting engines include the VBScript and JScript languages. There are also third party ActiveX Scripting engine versions of other popular languages, including Perl and Tcl.
This book covers only the VBScript language because this language is in many ways more approachable for newcomers to programming. In addition, the popularity of Visual Basic means that many people will already be familiar with the underlying syntax of VBScript, based as it is upon this language. However, if you prefer to use another language, then you are free to do so-that is one of the advantages of the ActiveX Scripting architecture. However, if you do use a language other than VBScript or JScript, you will have to ensure that the language engine is installed on all machines where your scripts are to be executed.
Organization of This Book
This book is divided into three parts and several appendices.
Part I, "WSH and the VBScript Language"
The first part of the book covers two topics: WSH and the VBScript language (with the exception of objects and classes, which are described in Part II, "Objects and Classes"). As such, the information in this part forms the foundation for using system-scripting technologies.
If you are already familiar with VBScript, you might wish to scan the information on WSH briefly and then skip ahead to Part 11. If you have not used VBScript before or if you are unfamiliar with computer programming, the material in Part I will provide you with all the core concepts needed to use the VBScript language effectively.
Part 11, "Objects and Classes"
Part 11 of the book covers objects and classes, and it explains the objectoriented paradigm and how this paradigm is used in system scripting. The focus of this part of the book is on the objects and features that are built-in to either WSH or VBScript. You will also find information here on how to construct your own "in-script" objects using VBScript.
Part 11 also shows how to use COM Objects. Many technologies and applications expose their functionality through COM Objects, and therefore, understanding how to access these objects is critical to using system scripting effectively.
Finally, Part II of the book also describes Windows Script Components, which is a technology that allows you to create your own COM Objects using VBScript. Windows Script Components provides an excellent way to break up large projects into smaller sub-projects and provides the foundations for dynamic script re-use.
Part III, "Sample Script Solutions"
Part III of the book builds upon the material in the earlier two parts to provide a library of complete, ready-to-use sample scripts. These scripts can be used "as-is" or as a starting point for a custom script project.
Part IV, "Appendices"
Finally, the appendices at the end of the book provide additional informa- tion that might be useful to system script authors.
Throughout this book, VBScript source code is shown in a monospace font using a mixed-case convention. However, the VBScript language is not casesensitive, and source code can be entered as desired. This may not be true of third party ActiveX Scripting languages-consult the specific language documentation for information on case sensitivity.
When describing VBScript and other syntax (instead of showing an example), items that must be entered exactly are shown in mixed case. Placeholders that must be replaced by appropriate values are shown in lower case italic. Optional items are shown in brackets, and vertical bar characters separate alternatives, where one item from a list must be selected. For example, the Do command syntax is: Do [While expression]
This example shows that the Do command can be optionally followed by a While clause, which consists of the keyword While followed by an expression.
Some sample scripts in the book are shown with accompanying line numbers. These line numbers are for reference purposes only-scripts do not include line numbers in the program text.
Before You Continue
Before continuing, you might want to take a few minutes to install the latest system scripting components on your computer. Appendix A provides details on where to obtain these components and how to install them. You might also want to look at Appendix B, which provides some links to additional scripting resources, tools, and technologies.
The information in this book is based upon versions 1.0 and 2.0 of Windows Scripting. The VBScript information is based upon version 5.0 of the VBScript engine. Refer to Appendix A for information on obtaining the most recent versions of all these components.
| Book: | Windows Script Host |
| Author: | Tim Hill |
| ISBN: | 1578701392 |
| ISBN-13: | 9781578701391 |
| Binding: | Paperback |
| Publishing Date: | 1999-10-22 |
| Publisher: | Pearson Education |
| Number of Pages: | 448 |
| Language: | English |
|
Please Note - * We sell only NEW book and do NOT sell old or used books. * The book images and summary displayed may be of a different edition or binding of the same title. * Book reviews are not added by BookAdda. * Price can change due to reprinting, price change by publisher / distributor. |
BookAdda (www.bookadda.com) is a premier online book store in selling books online across India at the most competitive prices. BookAdda sells fiction, business, non fiction, literature, AIEEE, medical, engineering, computer book, etc. The books are delivered across India FREE of cost. |