The book you need to succeed! Vbscript, jscript



Yüklə 12,95 Mb.
Pdf görüntüsü
səhifə15/91
tarix07.11.2018
ölçüsü12,95 Mb.
#78682
1   ...   11   12   13   14   15   16   17   18   ...   91

xxxv
 
Introduction 
JScript
var fs = new ActiveXObject(“Scripting.FileSystemObject”);
var f = fs.OpenTextFile (aFile, ForAppending)
f.WriteLine(theLine)
f.Close()
In-text references to source-code elements are highlighted with a monospace font, as in the follow-
ing sentence. The 
OpenTextFile
 method is used to open text files. Don’t confuse monospace type 
with in-text elements printed in bold. When you see bold text in the middle of a paragraph, it means 
that this is something you should type in at the keyboard, such as, “Type 
cls
 at the command 
prompt to clear the screen.”
What’s on the Companion Web site
On the companion Web site, you will find the following:
Sample code:

 Each chapter has its own subfolder on the Web site, and you will find all the 
code output that was discussed in each chapter organized accordingly.
What You’ll Learn from This Book
Every how-to book is supposed to teach its readers how to do something, and in the process convey 
some body of knowledge to the reader. PowerShell, VBScript and JScript Bible is no exception. This 
book teaches you about Windows scripting and includes in-depth coverage of related technologies.
PowerShell, VBScript and JScript Bible isn’t meant to be a do-everything guide to scripting. Rather, 
the book focuses on techniques you’ll use to script the Windows operating system. Chapter by chap-
ter, you learn how to create scripts. The detailed explanations provided are backed by hundreds of 
hands-on examples and over 300 complete source-code listings. This book also develops extensive 
utility libraries that you can use to quickly and efficiently perform complex tasks.
86804flast.indd   xxxv
86804flast.indd   xxxv
1/22/09   11:52:15 AM
1/22/09   11:52:15 AM


86804flast.indd   xxxvi
86804flast.indd   xxxvi
1/22/09   11:52:15 AM
1/22/09   11:52:15 AM


IN THIS PART
Chapter 1
Introducing Windows Scripting
Chapter 2
VBScript Essentials
Chapter 3
JScript Essentials
Chapter 4
PowerShell Fundamentals
Getting Started with 
Windows Scripting
P
art I of the PowerShell, VBScript, and JScript Bible intro-
duces you to the powerful administrative tool that is 
Windows scripting. You’ll get an overview of Windows 
scripting and its potential, and an introduction to three tech-
nologies you can use for Windows scripting: VBScript, JScript, 
and PowerShell. 
86804c01.indd   1
86804c01.indd   1
1/21/09   1:16:17 PM
1/21/09   1:16:17 PM


86804c01.indd   2
86804c01.indd   2
1/21/09   1:16:18 PM
1/21/09   1:16:18 PM


3
W
indows scripting gives everyday users and administrators the 
ability to automate repetitive tasks, complete activities while 
away from the computer, and perform many other time-saving 
activities. Windows scripting accomplishes all of this by enabling you to 
create tools to automate tasks that would otherwise be handled manually, 
such as creating user accounts, generating log files, managing print queues, 
or examining system information. By eliminating manual processes, you 
can double, triple, or even quadruple your productivity and become more 
effective and efficient at your job. Best of all, scripts are easy to create and 
you can rapidly develop prototypes of applications, procedures, and utili-
ties; and then enhance these prototypes to get exactly what you need, or 
just throw them away and begin again. This ease of use gives you the flex-
ibility to create the kinds of tools you need without a lot of fuss.
Introducing Windows Scripting
You’ve heard the claims about scripting and now you’re thinking, so what? 
What’s in it for me? You may be an administrator rather than a developer. 
Or maybe you’re a power user who helps other users from time to time. 
Either way, scripting will prove useful to your situation and needs. So in 
answer to the question, “What’s in it for me?” consider the following:
Introducing 
Windows Scripting
IN THIS CHAPTER
Introducing Windows scripting
Why script Windows?
Getting to know 
Windows Script Host
Understanding the Windows 
scripting architecture
86804c01.indd   3
86804c01.indd   3
1/21/09   1:16:18 PM
1/21/09   1:16:18 PM


4
 Part 
I
 
Getting Started with Windows Scripting
Would you like to have more free time? 

Windows scripting frees you from mundane and 
repetitive tasks, enabling you to focus on more interesting and challenging tasks.
Would you like to be able to analyze trends and be proactive rather than reactive?

 You 
can use Windows scripting to extract and manipulate huge quantities of information and 
turn out easy-to-use reports.
Would you like to be able to seize opportunities before they disappear?

 Windows 
scripting enables you to take advantage of opportunities and be more effective. You can 
solve problems quickly and efficiently.
Would you like to be a top performer and receive the praise you deserve? 

Windows 
scripting enables you to accomplish in hours or days what would otherwise take weeks or 
months with traditional techniques. You’ll be more successful and more productive at work.
Would you like to be able to integrate activities and applications? 

Windows scripting 
enables you to integrate information from existing systems and applications, allowing you 
to kick off a series of tasks simply by starting a script.
Would you like to have fun at work?

 Windows scripting can be fun, challenging, and 
rewarding. Give it a try and you’ll see!
If Windows scripting can do so much, it must be terribly complex, right? On the contrary—it is its 
simplicity that enables you to do so much, not complexity. Many Windows scripts are only a few 
lines long and you can create them in a few minutes!
Taking a look at Windows Scripting
Two different architectures are used for scripting in Windows. The older one uses the Windows 
Script Host and the newer one uses PowerShell. A lot of the tasks that can be carried out using the 
VBScript in the Windows Scripting Host can be transferred to PowerShell. However not all the tasks 
that can be run in PowerShell can be transferred to Windows Script Host scripts so easily. For a lot 
of organizations using various derivatives of Visual Basic—in Web pages, Office applications, 
Windows forms applications—makes a de-facto standard.
Windows Script Host Architecture
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host 
provides architecture for building dynamic scripts that consist of a core object model, scripting 
hosts, and scripting engines—each of which is discussed in the sections that follow.
Getting Started with Windows Script Host
Windows Script Host is a core component of the Windows operating system and, as such, is 
installed by default when you install Windows. Like other components, Windows Script Host 
can be uninstalled. It can also be upgraded through downloads or by installing service packs. To 
86804c01.indd   4
86804c01.indd   4
1/21/09   1:16:18 PM
1/21/09   1:16:18 PM


Yüklə 12,95 Mb.

Dostları ilə paylaş:
1   ...   11   12   13   14   15   16   17   18   ...   91




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə