you might encounter a situation in which you don’t want to install an
application or run the installation script if certain elements aren’t in
place on the target computer. For example, you might want to verify
that there’s enough disk space available before proceeding or that a
particular program file exists. This example uses a file to indicate
whether a computer should execute the installation script. This is a
simple text file that you create and copy to all the computers that
shouldn’t execute the script. If the file is found on the computer, the
script will be terminated. If the file isn’t found, the script will
The sample SMS Installer script routine shown in Figure 7
demonstrates how to test for the existence of a file, and you can
incorporate it into larger scripts. It provides a basic structure that
you can easily modify to meet other needs.
Figure 7. Sample SMS Installer script designed to find a file and perform an action.
script is designed to look for a specific file identified in the script
as Findfile.txt using the Search For File action. In the Actions list,
doubleclick Search For File to display the Search For File Settings
dialog box, shown in Figure 8.
Figure 8. The Search For File Settings dialog box.
the Search For File Settings dialog box, specify the file and path to
search for and whether to search all local drives, all network drives,
or both. The path that’s searched is determined by the Search Depth
value. A value of 0 indicates that the entire drive will be searched. A
value of 1 indicates that the root drive will be searched. Values of 2,
3, and higher indicate that the first directory level, second directory
level, and so on will be searched. In this example we’ll search all
the Remove Filename check box. If the file is found, the file and its
path will be stored in the variable FINDFILE. This option will remove
the file entry and keep just the path, which can be useful if you’re
trying to capture a specific path or need to rename a file, as we do in
begins by using Set Variable to define a variable named FINDFILE. This
variable is set to a default value of None to indicate that no file has
been found. The Search For File action looks for the file on all local
drives on the target computer. If the file is found, the file and its
full path are placed in FINDFILE, and the value of FINDFILE is no longer
None. Simple IF/THEN logic tests to determine whether FINDFILE is still
None. If it’s not, the file has been found, and we’ll rename it
Findfile.old. If the file hasn’t been found, we simply continue on with
the rest of the script. The script also includes display messages for
debugging purposes to alert us when the file has been found. You can
remove these messages after the existence of the file has been tested.
can easily modify this basic script routine to perform any number of
actions or tasks—for example, deleting the file, moving the file to a
new location, or creating a new file with the same name as an existing
file if that file isn’t found.