Other Methods of Running Scripts

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

For the most part, system administrators either run scripts from the command line or schedule scripts to run periodically. However, a number of other methods are available for running scripts.

Running Scripts on Remote Computers. The WshController object, a COM object included with WSH, allows your scripts to run other WSH-based scripts on remote computers. For more information about the WshController object, see "WSHController Object" later in this chapter.

Running Scripts from Windows Explorer. You can run a WSH script by double-clicking the script file in Windows Explorer. This will cause the script to run using the default script host. If the default script host is CScript, a command window will open and the script will run. However, the command window will close as soon as the script finishes running. This means that any output generated by the script will disappear as soon as the script finishes and the command window closes.

Running Scripts from the Context-Sensitive Menu. You can run a WSH script by right-clicking the script file in Windows Explorer and selecting the appropriate option: Open with Command Prompt if CScript is your default script host or Open if WScript is your default script host.

Running Scripts by using Drag and Drop. You can run a script by dragging one or more files or folders onto the script file in Windows Explorer. The script runs under the default host, and the full path to each file or folder dropped onto the script file is passed to the script host as a command-line argument.

For example, this script echoes the path name of each file or folder dropped onto it:

For Each strArgument in Wscript.Arguments     Wscript.Echo strArgument Next 

This method is commonly used for passing a list of file names as arguments to a script that performs an action on a set of files. For example, you might drag several files onto a script, and the script, in turn, might copy each of those files to a remote server.

The command interpreter limits the number of characters that can be passed by a program (or script) and all of its arguments to roughly 2048 characters. If you use the drag-and-drop feature to provide arguments to a script, be sure the total number of characters does not exceed the 2048 limit. The total number of characters can be determined by adding the length of the script s fully qualified path and file name, the length of each argument, and any white space used to separate each argument.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net