|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Services
Chapters
Feature Zones
|
Chapter 7 - Built-In WSHand VBScript ObjectsThe previous chapter introduced objects and the object-oriented paradigm. This chapter details some objects that are supplied as part of either VBScript or Windows Script Host, and that are, therefore, available to system script authors. Objects that are supplied by WSH are available to all system scripts, regardless of the language used. Objects that are supplied by VBScript are only available if the VBScript language is used for scripting. Therefore, if you use another script language, you will not have access to the VBScript objects. The file system object is also supplied as part of the VBScript. This object is described in Chapter 8, "File System Objects."
VBScript ObjectsVBScript provides the following objects to scripts:
The Err ObjectThe The
To generate a user-defined run-time error, first clear the Err object using the Err.Clear Err.Raise 1000, "This is a script-defined error", "Test Script" This example displays a message showing the description string followed by a colon and the source string. To intercept run-time errors and process them in scripts, use the On Error Resume Next After this statement executes, subsequent run-time errors do not cause script execution to terminate. Instead, the Err.Clear On Error Resume Next Err.Raise 100,"Script Error" If Err.Number Then Wscript.Echo "Error=", Err.Number In this example, the In the preceding example, the error was generated by the On Error Resume Next Err.Clear x = CInt("foo") If Err.Number <> 0 Then Wscript.Echo Err.Number, Err.Description, Err.Source Here, an attempt is made to convert the string "foo" into an integer. Because this is an invalid conversion, a run-time type mismatch error is generated. The information on this error is placed in the Err object, and this is then processed by the If statement. After an If an error occurs while an On Error Resume Next Wscript.Echo "Begin" Sub1 Wscript.Echo "End" Sub Sub1 Wscript.Echo "Enter Sub1" Err.Raise 100 Wscript.Echo "Leave Sub1" End Sub In this example, an Begin Enter Sub1 End Notice that the final On Error Resume Next Wscript.Echo "Begin" Sub1 Wscript.Echo "End" Sub Sub1 Wscript.Echo "Enter Sub1" Sub2 Wscript.Echo "Leave Sub1" End Sub Sub Sub2 Wscript.Echo "Enter Sub2" Err.Raise 100 Wscript.Echo "Leave Sub2" End Sub Here, the Because VBScript abandons execution of procedures only until it finds the most recently executed On Error Resume Next Wscript.Echo "Begin" Sub1 Wscript.Echo "End" Sub Sub1 Wscript.Echo "Enter Sub1" On Error Resume Next Sub2 Wscript.Echo "Leave Sub1" End Sub Sub Sub2 Wscript.Echo "Enter Sub2" Err.Raise 100 Wscript.Echo "Leave Sub2" End Sub This example modifies the previous example by adding an Begin Enter Sub1 Enter Sub2 Leave Sub1 End Structured Exception HandlingThe The assumption is that a large script might contain many procedures that interact in complex ways. It is possible that an error will occur when procedures are nested very deeply. Without the With the The RegExp ObjectThe A regular expression is a string that describes a match pattern. The match pattern provides a template that can be used to test another string, the search string, for a matching sub-string. In its simplest form, the match pattern string is just a sequence of characters that must be matched. For example, the pattern "fred" matches this exact sequence of characters and only this sequence. More sophisticated regular expressions can match against items such as file names, path names, and Internet URLs. Thus, the To test a search string against a match pattern, create a Dim oRE, bMatch Set oRE = New RegExp oRE.Pattern = "fred" bMatch = oRE.Test("His name was fred brown") Regular expression objects are created using the The The Each By default, the Dim oRE, oMatches Set oRE = New RegExp oRE.Pattern = "two" oRE.Global = True Set oMatches = oRE.Execute("two times three equals three times two") For Each oMatch In oMatches Wscript.Echo "Match:", oMatch.Value, "At:", oMatch.FirstIndex + 1 Next This example lists all the matches against the pattern "two" in the specified string. Simple match patterns, such as those shown in the previous example, provide no additional functionality over that provided by the Listing 7.1 RegExp.vbs Script '//////////////////////////////////////////////////////////////////////////// ' $Workfile: ShowArgs2.vbs $ $Revision: 5 $ $Date: 4/24/99 11:36a $ ' $Archive: /Scripts/ShowArgs2.vbs $ ' Copyright (c) 1999 Tim Hill. All Rights Reserved. '//////////////////////////////////////////////////////////////////////////// ' Process a regular expression pattern match ' First arg=regexp match pattern, second arg=search string Option Explicit ' Check for sufficient command line arguments Dim sPattern, sSearch If Wscript.Arguments.Count < 2 Then Wscript.Echo "usage: regexp <match-pattern> <search-string>" Wscript.Quit(1) End If sPattern = Wscript.Arguments(0) sSearch = Wscript.Arguments(1) ' Do the regular expression match Dim oRE, oMatches Set oRE = New RegExp oRE.Global = True oRE.IgnoreCase = True oRE.Pattern = sPattern Set oMatches = oRE.Execute(sSearch) ' Now process all the matches (if any) Dim oMatch Wscript.Echo "Pattern String: " & Chr(34) & sPattern & Chr(34) Wscript.Echo "Search String: " & Chr(34) & sSearch & Chr(34) & vbCRLF Wscript.Echo oMatches.Count, "Matches:" Wscript.Echo " " & sSearch For Each oMatch In oMatches Wscript.Echo " " & String(oMatch.FirstIndex, " ") & String(oMatch.Length, "^") Next '//////////////////////////////////////////////////////////////////////////// To use the RegExp.vbs script, execute the script with two command line arguments. Enter a match pattern as the first argument and a search string as the second argument. If either argument contains spaces or special shell characters, enclose the argument in double quotes. The script uses the Regular Expression SyntaxWithin the match pattern, letters, digits, and most punctuation simply match a corresponding character in the search string. A sequence of these characters matches the equivalent sequence in the search string. However, some characters within the match pattern have special meaning. For example, the "." (period) character matches any character except a new-line character. Thus, the match pattern "a.c" matches "abc" or "adc" or "a$c". The match pattern ".." matches any sequence of two characters. The special character "^" matches the start of the string. Thus, the match pattern "^abc" matches the string "abc", but not "123abc" because this string does not begin with "abc". Similarly, the special character "$" matches the end of the string, and so the pattern "red$" matches the search string "fred", but not "fred brown". Using both these characters allows a regular expression to match complete strings. For example, the pattern "abc" matches "123 abc that" and any other string containing "abc", whereas the pattern "^abc$" only matches the exact string "abc". The three characters "*", "+", and "?" are called modifiers. These characters modify the preceding character. The "*" modifier matches the preceding character zero or more times, the "+" modifier matches the preceding character one or more times, and the "?" modifier matches the preceding character zero or one time. For example, the pattern "a+" matches any sequence of one or more "a" characters, whereas the pattern "ab*c" matches "abc", "abbbbbc", and "ac", but not "adc" or "ab". A list of characters enclosed in brackets is called a range and matches a single character in the search string with any of the characters in brackets. For example, the pattern "[0123456789]" matches any digit character in the search string. Ranges such as this, where the characters are sequential, can be abbreviated as "[0-9]". For example, the pattern "[0-9a-zA-Z_]" matches a digit, letter (either upper or lower case), or the underscore character. If the first character of the range is "^", the range matches all those characters that are not listed. For example, "[^0-9]" matches any non-digit character. Ranges can be combined with modifiers. For example, the pattern"[0-9]+" matches any sequence of one or more digit characters. The pattern "[a-zA-Z][a-zA-Z_0-9]*" matches a valid VBScript variable name, because it only matches sequences that start with a letter and are followed by zero or more letters, digits, or underscore characters. To match a character an exact number of times, follow the character in the pattern by a count of matches required enclosed in braces. For example, the pattern "a{3}" matches exactly three "a" characters, and it is equivalent to the pattern "aaa". If a comma follows the count, the character is matched at least that number of times. For example, "a{5,}" matches five or more "a" characters. Finally, use two counts to specify a lower and upper bound. For example, the pattern "a{4,8}" matches between four and eight "a" characters. As with other modifiers, the pattern count modifier can be combined with ranges. For example, the pattern "[0-9]{4}" matches exactly four digits. Use parentheses in the match pattern to group individual items together. Modifiers can then be applied to the entire group of items. For example, the pattern "(abc)+" matches any number of repeats of the sequence "abc". The pattern "(a[0-9]c){1,2}" matches strings such as "a0c" and "a4ca5c". There is a difference between matching the pattern "abc" and the pattern "(abc)+" using the RegExp object. Matching the pattern "abc" against the search string "abcabcabc" generates three individual matches and results in three Match objects in the The "I" vertical bar character separates lists of alternate sub-expressions. For example, the pattern "abIac" matches the strings "ab" or "ac". The vertical bar separates entire regular expressions. The pattern "^abIac$" matches either the string "ab" at the start of the search string or the string "ac" at the end of the search string. Use parentheses to specify alternates within a larger pattern. For example, the pattern "^(abIac)$" matches the exact strings "ab" or "ac" only. To match any of the special characters literally in a pattern, they must be preceded by a back-slash character, which is known as an escape. For example, to match a literal asterisk, use "\*" in the pattern. To match a back-slash itself, use two back-slash characters in the match pattern. The following characters must be escaped when used literally within a match pattern: . (period) * + ? \ ( ) [ ] { } ^ $
There are also several additional escape sequences that provide useful shorthand for more complex patterns:
Finally, certain escapes can match non-printing characters, as follows:
The special escape "\n", where Regular Expression ExamplesRegular expression match patterns provide a powerful way to validate the syntax of strings. For example, a script can obtain a command line argument that is the name of a file to create. Before creating the file, a script might want to validate that the command line argument is a valid file name. A regular expression can be used for this purpose. The ParseArgs.vbs script in Chapter 3 processed command line arguments of the form name=value. This script is simplistic in that it simply breaks apart each argument at the "=" sign - no attempt is made to check if the name and value parts are valid. The following regular expression matches these command line arguments: [^=]+=.* This match pattern is interpreted as follows: The range "[^=]" matches any character that is not an "=" sign. The "+" modifier following the range means that the pattern matches any set of one or more characters that are not "=" signs. The next "=" sign in the pattern matches a literal "=" sign (that is, the separator between the name and value parts). Finally, the ".*" pattern matches any sequence of zero or more characters. Parentheses can be used to make the meaning more clear. For example: ([^=]+)=(.*) This example is identical to the previous example, but the parentheses help make the individual parts of the pattern more understandable. Typically, the name in the previous example should be restricted to a valid name. We define valid names as a letter followed by zero or more letters, digits, or underscores. This yields a new regular expression as follows: ([a-zA-Z]\w*)=(.*) Here, the pattern "[a-zA-Z]" matches any single letter. Then the pattern "\w*" matches zero or more letters, digits, or underscores, using the "\w" escape as a shorthand for "[0-9a-zA-Z]". The previous regular expression does not allow spaces before or after the name. For example, only the first of these strings matches the expression: account=123456 account = 575888 account = 5544 The following regular expression corrects this by adding optional leading and trailing whitespace around the name: (\s*)([a-zA-Z]\w*)(\s*)=(.*) The new addition, "\s*", matches zero or more whitespace characters. Here is a sample script that uses this expression to validate commandline arguments: Dim oRE, oMatches, oMatch, sArg Set oRE = New RegExp oRE.Global = True oRE.IgnoreCase = True oRE.Pattern = "(\s*)([a-zA-Z]\w*)(\s*)=(.*)" For Each sArg In Wscript.Arguments Set oMatches = oRE.Execute(sArg) If oMatches.Count > 0 Then Wscript.Echo "Valid argument: " & sArg Else Wscript.Echo "Invalid argument: " & sArg End If Next As another example, we can define a command line switch to be an argument of the form: /name[:|=value] Another way to define a command line switch is an argument that begins with a slash character and ends with a name. The name can be followed by an optional value that is delimited with either a colon or an equal sign character. The following are valid example switches: /b /file=c:\myfile.txt /debug:on Here is the regular expression that matches a command line switch: (\s*)/([a-zA-Z]\w*)((=I:)(.*)I) This complex expression breaks down as follows:
Using the
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "AllUsersStartMenu" | Folder where items in Start menu for all users are stored |
| "AllUsersDesktop" | Folder where items visible on all users desktops are stored |
| "AllUsersPrograms" | Folder where items in Start Programs menu for all users are stored |
| "AllUsersStartup" | Folder where items in Start Programs Startup menu for all users are stored |
| "Desktop" | Folder for this user’s desktop items |
| "Favorites" | Folder for this user’s Internet favorites |
| "Fonts" | Folder where fonts are stored |
| "MyDocuments" | Default folder where user storesdocuments |
| "Programs" | Folder where items in Start Programs menu for this user are stored |
| "Recent" | Folder where shortcuts to recently open documents for this user are stored |
| "StartMenu" | Folder where items in Start menu for this user are stored |
| "Startup" | Folder where items in Start Programs Startup menu for this user are stored |
The .Run method of the WshShell object allows a script to execute any other application or command line. The method takes at least one argument, which specifies the command line to execute, including any command line arguments. For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") oShell.Run("notepad")
This example starts a copy of Windows Notepad. The .Run command accepts any command that can be typed at the Windows command shell prompt.
The .Run method accepts two optional arguments. The first argument specifies how any applications started by the .Run method should appear on the desktop, as follows:
The final argument to the .Run method determines if the script waits for the command to complete execution. If this argument is False (the default), the script continues executing immediately and does not wait for the command to complete. In this case, the .Run method always returns 0. If the argument is True, the script pauses execution until the command completes, and the return value from the .Run method is the exit code from the application. For example:
Dim oShell, nError Set oShell = CreateObject("Wscript.Shell") nError = oShell.Run("net start spooler", 1, True) If nError = 0 Then Wscript.Echo "Spooler service started."
The WshShell object provides three methods that provide basic access to the system registry:
.RegDelete method deletes a registry key or value.
.RegRead method reads a registry value.
.RegWrite method writes a registry value. Note
Modifying the registry, though sometimes necessary, should be done with caution. Inadvertent changes to the registry may result in system instability or the inability to boot the operating system correctly. Always debug and validate scripts that modify the registry on test systems that do not contain live data and can be recovered in the event of catastrophe.
All the methods access the items in the registry by key name or value name. The name must begin with one of the predefined key names:
HKEY_CURRENT_USER or HKCU to access the per-user information for the current user
HKEY_LOCAL_MACHINE or HKLM to access the per-machine information
HKEY_CLASSES_ROOT or HKCR to access the per-machine class information
HKEY_USERS to access other users and the default user
HKEY_CURRENT_CONFIG to access configuration data Following the predefined key name are one or more key names separated by back-slash characters. A name that ends with a back-slash is assumed to specify a key name, otherwise the name is assumed to specify a value name.
Use the .RegDelete method to delete a key or value from the registry. Specify the name of the item to delete. For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") oShell.RegDelete "HKCU\Software\AcmeCorp\WindowSize" oShell.RegDelete "HKCU\Software\AcmeCorp\"
Here, a registry value and then a key are deleted. The .RegDelete method cannot delete a key if it contains any subkeys, although it will delete a key that contains one or more values.
The .RegRead method reads a value from the registry. If the name specifies a key, the default value for that key is read, otherwise the specified value is read from the specified key. For example:
Wscript.Echo oShell.RegRead _
"HKLM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
The .RegWrite method writes a value into the registry. If the name specifies a key, the default value for that key is written. Otherwise, the specified value is written. For example:
oShell.RegWrite "HKCU\Software\AcmeCorp\LastRunDate", Date
The .RegWrite method supports one optional argument that specifies the type of data to write to the registry. If can be one of:
The WshShell object provides access to two methods that can be used to control Windows applications. These methods are used only with applications that are not COM based. COM applications and objects are manipulated using the object techniques described in Chapter 6.
For older legacy applications, the WshShell object provides two methods, .AppActivate and .SendKeys, that can be used to control the application.
The .AppActivate method is used to activate a running application and switch the input "focus" to that application. This method does not run an application; it only switches the focus to the application. To run an application, use the .Run method.
To activate an application, specify its window title (the text displayed at the top of the window) as a single argument. For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") oShell.AppActivate "Calculator"
Here, the application, named Calculator (the Windows calculator applet), is activated.
The .AppActivate method first tries to find a window with title text that exactly matches that supplied as an argument. If no match is found, the method looks for a window whose title begins with the text specified. Finally, if there is still no match, the method looks for a window whose title ends with the text specified. This allows .AppActivate to work with applications that add the document name to the window title text.
The second method provided to control legacy applications, .SendKeys, is used to send keystrokes to the application that currently has the focus. Thus, before using .SendKeys, the .AppActivate method is typically used to ensure that the correct application receives the keystrokes specified.
The .SendKeys method sends keystrokes to the application as if they had been typed at the system keyboard. Thus, by sending the correct sequence of keystrokes, the application can be driven by a script as if it were being used interactively.
To use .SendKeys, specify a sequence of keystrokes as a string argument. For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") oShell.AppActivate "Calculator" oShell.SendKeys "1000"
Here, the calculator program is sent the value 1000.
Certain characters in the string argument to the .SendKeys method have special meanings. These are shown in Table 7.2.
Table 7.2 Special Characters in .SendKeys String
Characters Meaning
| {BS} | Sends Backspace key. |
| {BREAK} | Sends Break key. |
| {CAPSLOCK} | Sends Caps Lock key. |
| {DEL} | Sends Delete key. |
| {DOWN} | Sends down-arrow key. |
| {END} | Sends End key. |
| {Enter} or ~ | Sends Enter key. |
| {ESC} | Sends Esc key. |
| {HELP} | Sends Help (F1) key. |
| {HOME} | Sends Home key. |
| {INS} | Sends Insert key. |
| {LEFT} | Sends left-arrow key. |
| {NUMLOCK} | Sends Num Lock key. |
| {PGDN} | Sends Page Down key. |
| {PGUP} | Sends Page Up key. |
| {RIGHT} | Sends right-arrow key. |
| {SCROLLLOCK} | Sends Scroll Lock key. |
| {TAB} | Sends Tab key. |
| {UP} | Sends up-arrow key. |
| {Fn} | Sends Fn key (for example, {F1} sends F1, {F10} sends F10, and so on). |
| {+} | Sends + key. |
| {^} | Sends ^ key. |
| {%} | Sends % key. |
| {~} | Sends ~ key. |
| {(} | Sends open parenthesis key. |
| {)} | Sends close parenthesis key. |
| {{} | Sends open brace key. |
| {}} | Sends close brace key. |
| +key | Sends key with the Shift key down. |
| ^key | Sends key with the Ctrl key down. |
| %key | Sends key with the Alt key down. |
| {keycount} | Sends key exactly count times. |
In the .SendKeys string, characters with special meanings, such as "+" or "~", must be enclosed in braces if they are to be sent literally. Otherwise, as shown in Table 7.2, they are used to modify the way characters are sent. For example, the string "^S" sends a single Ctrl+S keystroke to the application, whereas the string "{^}S" sends a carat character followed by an upper case S.
The "+", "^", and "%" characters can be used in combination. For example, the string "+^A" sends the Shift+Ctrl+A keystroke to the application.
To send a sequence of keys with a modifier key (Ctrl etc.) held down, enclose the keys in parentheses. For example, the string "+(ABC)" sends the three keys "A", "B", and "C" with the Shift key down.
To specify a repeated keystroke, specify the key and repeat count in braces. For example, the string "{X 10}" sends 10 "X" keys to the application.
The WshShell object provides a method, .LogEvent, to add an event to the system event log. On Windows NT and Windows 2000, this method adds an event to the application event log. On Windows 9x, this method adds the event to a file named WSH.log in the Windows directory.
The .LogEvent method takes three arguments. The first argument specifies the event type. Event types are shown in Table 7.3.
Table 7.3 Event Types
Code Meaning
| 0 | Success event. Indicates that an action was successful. |
| 1 | Error event. Indicates an error. |
| 2 | Warning event. Indicates a condition that should be corrected but was not fatal. |
| 4 | Information event. Provides general information. |
| 8 | Audit Success. An auditing event that succeeded. |
| 16 | Audit Failure. An auditing event that failed. |
The second argument to the .LogEvent method specifies an arbitrary text string to be logged. This typically contains an informative message describing the event being logged.
The final argument, which is optional on Windows NT and Windows 2000 and ignored on Windows 9x, specifies the name of the computer where the event is to be logged. The default, if not specified, is to log the event on the local computer.
For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") oShell.LogEvent 1, "Script processing failed."
The WshShell provides two ways to access the system environment strings. The .ExpandEnvironmentStrings method processes a string and replaces any references to environment variables with the values of those variables. Environment variables are enclosed in "%" signs as usual for command shell processing. For example:
Dim oShell Set oShell = CreateObject("Wscript.Shell") Wscript.Echo oShell.ExpandEnvironmentStrings("The temp dir is %TEMP%")
The .Environment property of the WshShell object returns a WshEnvironment object that can then access individual environment variables. The object returned can access environment variables in one of four sets by specifying a string argument as follows:
HKEY_LOCAL_MACHINE portion of the registry.
HKEY_CURRENT_USER portion of the registry.
The "Process" set is typically used when reading variables. To make a change to a variable persistent, use either the "System" or the "User" sets.
Once the WshEnvironment object has been obtained, variables can be manipulated individually. The WshEnvironment is a collection object. For example:
Dim oShell, oEnv Set oShell = CreateObject("Wscript.Shell") Set oEnv = oShell.Environment("Process") For Each sItem In oEnv Wscript.Echo sItem Next
To change the value of an environment variable or add a new variable, specify the name of the item to change or add and assign it a value. For example:
oEnv("Path") = oEnv("Path") & ";c:\myapp"
This example adds an additional path name to the end of the PATH environment variable.
The .Remove method deletes an environment variable. For example:
oEnv.Remove "TempDir"
Note that changes to the process set of environment variables are local to the script process and any processes the script creates using the WshShell.Run method. They are not visible to other processes in the system.
The WshShell object provides access to two distinct types of shortcuts: the file shortcut and the URL shortcut. Both are stored in small files. File shortcuts provide a link to a file in another location, whereas URL shortcuts provide a link to a Web site or Internet resource.
To create a shortcut, use the .CreateShortcut method. Specify the full pathname of the shortcut file to be created. This filename must end with a file type of either .LNK for regular file shortcuts or .URL for Internet URL shortcuts. For example:
Dim oShell, oSC, oURL Set oShell = CreateObject("Wscript.Shell") Set oSC = oShell.CreateShortcut("c:\MyDocs.LNK") Set oURL = oShell.CreateShortcut("c:\MySite.URL")
After the shortcut object is created, set the properties of the shortcut and then use the .Save method to save the information in the shortcut file.
Regular file shortcuts support the following properties:
.Arguments Use this property to set additional arguments that are passed to the target application when the shortcut executes.
.Description Use this property to add descriptive text to the shortcut.
.IconLocation Use this property to specify the location of an icon for the shortcut. Specify a string containing a path name and icon index. If no icon is specified, the icon appropriate for the shortcut target is used.
.TargetPath Use this property to specify the full pathname of the target application or document. Always specify a full path name, including a drive letter or UNC name.
.WorkingDirectory Use this property to specify the directory to be used as the working directory when the shortcut executes. The default is the current working directory.
.WindowStyle Use this property to specify the initial window location when the application starts. See the discussion of the WshShell.Run method earlier in this chapter for more information on window styles. Internet URL shortcuts support the following properties:
.TargetPath Use this property to specify the full URL to the internet location. For example:
Dim oShell, oSC, oURL Set oShell = CreateObject("Wscript.Shell") oSC = oShell.CreateShortcut("c:\MyDocs.LNK") oURL = oShell.CreateShortcut("c:\MySite.URL") oSC.TargetPath = "e:\Users\Me\MyDocs" oURL.TargetPath = "http://www.macmillantech.com" oSC.Save oURL.Save
The VBScript Err, RegExp, and Dictionary objects provide additional features to assist in the development of scripts. The RegExp object is particularly suitable for decoding and validating textual information. Dictionaries are useful when items of information must be stored and indexed by a text key.
The Wscript object provides access to various types of script-level information, such as the name of the script currently executing. The object also provides access to the WshArguments object, which encapsulates the script command-line arguments.
The WshNetwork object provides access to logon account information as well as to file and printer shares. The WshShell object provides access to several other internal objects, including objects to manipulate the system environment strings and system shortcuts. It also provides access to the system registry and various special folders.
| You must Sign In to use this message board. | ||||||||||||
|
||||||||||||
|
||||||||||||
|
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms
of Use
Last Updated: 12 Mar 2001 Editor: Chris Maunder |
Copyright 2001 by New Riders Everything else Copyright © CodeProject, 1999-2008 Web13 | Advertise on the Code Project |