Passing command line options in a WiseScript executable
| Article:HOWTO4341 | | | Created: 2006-07-20 | | | Updated: 2006-07-31 | | | Article URL http://www.symantec.com/docs/HOWTO4341 |
Question
How do I pass command line options into Wisescript executable?
Answer
Many times when working with an installation or support script, you might want to use the command line to customize the execution of the .EXE. WiseScript lets you do just that via a built-in variable called CMDLINE. This article outlines how you can make use of CMDLINE, access portions of text, and avoid common pitfalls.
|
.EXE Path |
Option 1 |
Option 2 |
Option 3 |
|
C:\SETUP.EXE |
/F |
/q |
C:\Test Folder\test_file.dat |
|
.EXE Path |
Option 1 |
Option 2 |
Option 3 |
Option 4 |
|
C:\SETUP.EXE |
/F |
/q |
C:\Test |
Folder\test_file.dat |
The second disadvantage is that ordering is vitally important. In the previous example, if you look for the /q option, then you need to look at each individual command line section until you find that command. If you need to ensure the user also provides a path to a .DAT file after using the /q option, then either check the next command line section and assume that the .DAT file is there, or begin searching each section of the command line until you locate the data, which could be quite time consuming. WiseScript takes a different approach to storing the command line options passed to the .EXE. WiseScript stores the entire contents of the command line, including all spaces and quotes into a single variable called CMDLINE. The installation developer is free to parse the command line contents using whatever method best suits their installation methodology. This article includes a small .WSE sample script that demonstrates how to take the CMDLINE variable and parse it into the conventional sections as outlined above. If you are not looking for a full command line parsing routine, you can do simple checks with the built in WiseScript conditionals to check for existence of your own specific substrings. Common Pitfalls:
- WiseScript passes all command line switches it finds, including those that have special meaning to all WiseScript .EXEs. Avoid using common switches such as /s, /x, and /t since these all have specific meanings to all WiseScript .EXEs.
- The WiseScript conditional If Contains checks for any occurrence of a specified substring. For instance, the strings /c and /checkin would both be true if you were checking for the substring /c.
- The CMDLINE variable does not group any command line options by quotes. If you look for a specific substring or want a certain portion of the CMDLINE variable that may be enclosed in quotes, you need to include your quotes in the search criteria. See the attached sample provides an example of how to accomplish this.
By using the methods described in this article, you can affectively pass information to your WiseScript .EXEs on the command line with a minimum of formatting loss. By avoiding common pitfals and using the sample script provided with this article, you can easily use the CMDLINE variable. For additional information about the CMDLINE variable, contact Technical Support via the
Legacy ID
24919
Article URL http://www.symantec.com/docs/HOWTO4341
Terms of use for this information are found in Legal Notices









Thank you.