Wednesday, 26 November 2014
Wednesday, 19 March 2014
Jscript Function Statement, Jscript Functions Vs Jscript Functions, Jscript Functions Example, Jscript Blog.
In order to create a JScript, you only need to open your text editor, create a plain text file, add a few JScript statements to it, and then save it with a .js file extension. For example, create a new JScript called my_first_prog.js and add the following statements to it.
//Script 1.5 - Your first JScript
WScript.Echo("Well To ProgrammingDost!");
The first statement is a comment that was embedded within the file to document the script's name and purpose. The second statement displays a text message. The composition of the second statement is as follows. First the WScript object is referenced. This object is different from the WScript execution host. Then a method called Echo, which belongs to the WScript object, is executed and passed the text string "Well To ProgrammingDost!". Don't worry if this all sounds a little confusing or overwhelming now. By the time that you get through Sunday evening, you'll understand how this stuff works. For now, just follow along and focus on the steps involved in creating and executing your first JScript.
When executed by either the WScript or CScript execution host, this JScript displays its message. However, depending on which execution host you choose to use when running the script, the results will vary significantly.
If you were to run the scripts directly from the Windows desktop by double-clicking on it, Windows would, by default, run it using the WScript execution host. As a result, the script's output would be displayed in the form of a graphical pop-up dialog.
You can also use the WScript execution host to run scripts from the Windows command prompt,in which case the script will run exactly as if you had started it from the Windows desktop.
Even some of the most experienced computer users have limited experience working with the Windows command prompt and little if any understanding of the Windows commands that are available. However, if you plan on becoming a serious JScript programmer, you need to get comfortable working with the Windows shell.
The Windows shell provides a text-based interface between the user and the operating system. Instead of using the computer's mouse to point and click your way through the Windows graphical user interface, you work with the Windows shell by typing in text commands. The Windows shell translates these commands into a format the operating system can understand. Likewise, the Windows shell translates any output returned by the operating system into a format that people can understand.
You enter commands for the Windows shell to process by typing them in at the Windows command prompt. For example, on a computer running Windows XP, you would start up a new Windows shell session by clicking on Start, All Programs, Accessories, and then Command Prompt.
As a shortcut, you can start up a new Windows shell session and access the Windows command prompt by clicking on Start, Run, typing CMD, and then clicking on OK.
If your script resides in a folder other than the folder upon which the Windows shell is currently focused, you must supply the complete path to the folder where the script is stored. For example, if your script were stored in C:\Jscripts, then you would need to use the following command to run it using the WScript execution host.
If you are faster at the keyboard than you are with your mouse then you can also close the Command Prompt windows by typing EXIT and pressing the Enter key.
What Is A Jscript File, What Is A Jscript Script File, Jscript Tutorial, Jscript Examples, Jscript Download, Jscript Array, Jscript Alert.
Jscript and VBScript are the two default scripting languages which are supplied by the Microsoft to use with the WSH (Windows Script Host). Both the languages are pretty much similar to each other. These are very useful when it comes to the automating small tasks.
The main reason for using JScript and the WSH (Windows Script Host) is to save you time by automating system tasks. At the heart of every one of Microsoft's Windows operating systems is an intuitive graphical user interface (GUI). This GUI is designed to make the computer easy to use. All that you have to do is grab on to the mouse and point and click your way around.
Unfortunately, the GUI is not well suited to many tasks, particularly those that are highly repetitious or that involve many steps. For example, suppose that you are responsible for defining new user accounts on a shared computer in your department at work, and one day your boss comes in with a floppy disk containing a file with a list of 100 newly hired employees.
Using the GUI, you'd probably spend hours in front of the computer defining new user accounts, during which time no one else could use the computer to get any work done. On the other hand, you could write JScript and use the WSH to run it in less than an hour. This script could even be designed to read the file provided by your boss and to create a new user account for each name stored in the list. Once executed, the script would create the new user accounts within seconds. Best of all, once it is written, you could return and run the script again in the future with no additional work on your part to create new user accounts.
The WSH is an optional software element that supports the execution of scripts on Windows operating systems. It is tightly coupled with the operating system, meaning that it provides direct access to a number of Windows resources, including these:
Ø The Windows desktop and Start menu
Ø The Windows Quick Launch Bar
Ø The Windows file system
Ø Local and network printers and drives
Ø Windows applications
Ø Windows services
Ø User accounts
Ø The Windows registry
The WSH gives the most complete scripting environment available today for all Windows operating systems. When combined with a scripting language such as JScript, it provides a perfect platform for developing scripts that can automate virtually any Windows task.
Regardless of which of the Microsoft operating systems you own or support, you will want to make sure that you have upgraded the version of the WSH that is installed to the most current version. Microsoft provides access to the most current version of the WSH through its official scripting Web site, msdn.microsoft.com/scripting, where you can download WSH for free.
A Brief Overview of the WSH Architecture
The WSH provides built-in support for both JScript and VBScript. In addition, it can support any third-party, WSH-compatible scripting language, including PERL, Python, and REXX. In the future, third-party software developers may provide other WSH-compatible scripting languages. Microsoft designed the WSH to be very extensible, as evidenced by the number of third-party scripting languages that has already been set up to work with it. However, because JScript and VBScript are supplied with the WSH, they are the most commonly used scripting languages.
The WSH is a 32-bit application. Its architecture consists of three separate layers. First there are the various WSH-supported scripting engines. These scripting engines interpret script statements and pass them on to an execution host for processing.
The WSH provides two different execution hosts. The WScript execution host is designed to support the execution of scripts directly from the Windows desktop. The CScript execution host, on the other hand, is designed to support the execution of scripts from the Windows command prompt. Each of these execution hosts exists as a separate executable file named Wscript.exe and Cscript.exe, respectively.
With one exception, the WScript and CScript execution hosts provide the same level of functionality. This exception is the WScript execution host's capability to enable scripts to display text messages and collection input from users using graphical pop-up dialogs. This makes the WScript execution host the proper choice for scripts that need to interact directly with users. The CScript execution host, on the other hand, generally is used to run scripts that do not interact with users or to run scripts for users who are comfortable working from the Windows command prompt. However, the WScript execution host can be used to run scripts from the command line as well. Unless your script is designed to generate graphical pop-up dialogs, the choice of which script execution host to use is completely arbitrary.
The purpose of the WSH core object model is to provide access to Windows resources. It accomplishes this by defining objects that represent actual resources. These objects can then be accessed and manipulated by scripts, thus allowing the scripts to access and manipulate the resources that the objects represent. Examples of the types of objects that the WSH makes available include objects that represent Windows shortcuts, files, folders, and disk drives. The WSH also provides objects that represent network resources such as network drives and printers. On top of all this, the WSH object model also provides access to system resources such as Windows events logs and the Windows registry.
Every object that is presented by the WSH is associated with a collection of properties and methods. For example, a file is an example of an object. File objects have file names and file extensions. By accessing these file object properties, your JScripts can locate files that they want to work with. In addition, by modifying file object properties, your JScripts can rename files and change their file types.