Documente Academic
Documente Profesional
Documente Cultură
scripts that run on Windows Operating Systems. Scripts are small text based files written in English like programming language. They can be executed from the Windows command prompt or directly from the Windows desktop. Scripts provide quick & easy way to automate lengthy tasks that would take too much time or effort using the Windows GUI(graphical user interface).
WSH components
WSH is a 32-bit application that is made up of a number of
statements that make up scripts & translate them into machine readable code that computer can understand & execute. WSH provides each script with a number of resources. WSH provides script engines for processing scripts. By default WSH can process scripts written in Jscript or VBScript. WSH is designed in a modular fashion. It allows Microsoft & third-party software developers to add support for additional scripting engines. Script Execution Engines have already been developed for Perl, Python, & Rexx
host to process a script after the script engine has interpreted the script. WSH supplies two different script execution hosts:
Cscript.exe An execution host that enables script to execute from the Windows command prompt & display text based messages.
Wscript.exe An execution host that enables script to execute from the Windows desktop, display messages, & collect user input using graphical pop up dialogs.
graphical pop-up dialogs. In fact, the messages can still be displayed using the Cscript execution host. You can choose any of the execution host depending on your personal choice. However, if you wish to run your script in background & has no need to interact with the user, you should use Cscript.exe.
execution of scripts. WSH core object model provides VBScript with direct access to windows resources. WSH Core Object Model provides access to the certain areas that include:
Windows desktop Windows Start Menu Windows Applications
folder, disk drive, printer, etc) in a format that allows scripts to view, access & manipulate them. Each exposed object has associated properties & methods that scripts can use to interact with an object, as well as affect its behavior or status.
Windows Shell
Windows Shell
A text based interface between user or scripts & the
operating system. Windows command prompt is used to communicate with the windows shell. The commands we enter are translated by windows shell into the format that the operating system can process. The operating system returns the results to the windows shell which displays them in the windows console.
you need to understand WSH Core object model. Understanding this model provides you with technical insights required to develop the script. This model provides programmatic access to windows resources. There are 14 objects in WSH Core object model. Each of these objects provides access to particular category of Windows resources.
WSH Arguments
WSH Controller
WSH Shell
WSH Network
WSHNamed
WSHUnnamed
WSHRemote
WshShortcut
WSHEnvironment
WshUrlShortcut
WSHSpecialFolder
WSHScriptExec
WSHRemoteError
Wscript
Wscript object is referred to as a public or exposed objects. Wscript Object provides access to a number of very useful methods. The properties & methods of Wscript object can be accessed directly
Establishes an instance of specified object Prevents a script from accessing a previously instantiated object
Echo
Each of these objects must be instantiated within your script using the Wscript objects CreateObject method.
Methods Of Instantiation
Object WshArgument WshNamed WshUnnamed WshRemote WshRemoteError WshShortcut WshUrlShortcut WshEnvironment WshSpecialFolders WshScriptExec Method Of Instantiation Wscript.Arguments Wscript.Arguments.Unnamed Wscript.Arguments.Named WshController.CreateScript WshRemote.Error WshShell.CreateShortcut WshShell.CreateShortcut WshShell.Environment WshShell.SpecialFolders WshShell.Exec()
WScript
WSH Root Object Provides access to rest of the objects in the core model
Properties Arguments ScriptFullName StdOut Methods ConnectObject() CreateObject() DisconnectObject() Quit() Sleep() Echo() FullName ScriptName Version InteractiveName StdErr Path StdIn
WSHArguments
This method enables you to access command line
WSHController
Provides the capability to create a remote script process
Properties Does not support any properties Methods CreateScript()
WSHRemoteError
Provides access to information on errors produced by
remote scripts.
Properties Description SourceText Methods Does not support any methods Line Source Character Number
WSHNetwork
Provides access to a number of different network resources
WSHShell
Provides access to windows registry, event log,
WSHShortcut
Provides script with methods & properties for creating &
Special folders
VBScript can use some special folders to place shortcuts on. These include: Desktop
Represents Windows Desktop Programs Represents Program Menu under Windows Start Menu Start Menu Represents Start Menu
All these folders are user specific. Changes made to these special folders affect only the user that run the script that changes them. Any other user who is sharing your computer will not have his desktop affected.
Special Folder
To make the change for all the users logging on to a
AllUsersPrograms
WSHUrlShortcut
Provides script with methods & properties for creating &
WshEnvironment
This object provides access to windows environment
variables
Properties Item Methods Remove() Count() Length
WSHSpecialFolders
Provides access to special windows folders that allows
scripts to configure the start menu, Quick Launch Toolbar & other special Windows folders.
Properties Item Methods Count()
WSHScriptExec
Provides access to error information from scripts run using
WshNetwork
Examples