Using the %programdatadir Variable
<< Click to Display Table of Contents >> Navigation: Robo-FTP User's Guide > Script Programming > Internal Script Variables > Using the %programdatadir Variable |
The value of the %programdatadir variable is useful when developing command scripts that will be run on multiple computers or by multiple users.
Suppose your script reads a file named UploadList.txt that is stored in the ProgramData folder. The proper path to this file depends on the how the script was launched and the version of Windows installed on the computer. If the script was launched by a Windows account in the administrators group, the ProgramData folder will be located under the Robo-FTP installation folder but, if it was launched by a non-administrative user, the folder will be under the user's My Documents folder. Furthermore, the Robo-FTP installation folder is itself located under a folder named "Program Files" on 32-bit Windows and "Program Files (x86)" on 64-bit Windows. The %programdatadir allows the script developer to ignore this complexity and focus on the automation logic.
In the following example, the %programdatadir variable is used to build a path to a file that contains a list of files to be uploaded.
SET ListFile = %programdatadir + "\project\UploadList.txt"
IFNFILE ListFile GOTO done
READFILE ;; reset file row counter
:upload_loop
READFILE ListFile row
IFERROR GOTO done
SENDFILE row
GOTO upload_loop
:done
DELETE ListFile
It is a good idea to use the ProgramData folder whenever possible because the entire contents of this folder are included in the Settings file created by the EXPORT command. If all of your external dependencies are stored in this folder it will be easier to restore or replicate a Robo-FTP installation across the enterprise by using the IMPORT command to load a settings file created on a single master installation of Robo-FTP.
Related command(s): EXPORT, IMPORT
See also: Internal Script Variables