Syntax:

GETENV(variable)

  • variable: name of the environment variable.

Remarks:

  • The system environment variables are set by the operating system, not ScriptFTP. See the section below the script examples for a full list of them.
  • This command is useful to retrieve system inforation or paths. For example, the path to the windows temp directory, the path to the user desktop, the user name, etc.

Example:

# Show the path
p=GETENV("PATH")
PRINT(p)
 
# Log to C:\windows\temp\log-YYYYMMDD.txt
$logfile=GETENV("TEMP")."log-".GETDATE(FORMAT3).".txt"
LOGTO($logfile)
 
OPENHOST("ftp.scriptftp.com","john","123456")
PUTFILE("C:\ClientDocs\*.*",SUBDIRS)
CLOSEHOST

Annex:

List of Windows environment variables:

Environment variable

Description

ALLUSERSPROFILE Returns the location of the All Users Profile.
APPDATA Returns the location where applications store data by default.
CD Returns the current directory string.
CMDCMDLINE Returns the exact command line used to start the current Cmd.exe.
CMDEXTVERSION Returns the version number of the current Command Processor Extensions.
COMPUTERNAME Returns the name of the computer.
COMSPEC Returns the exact path to the command shell executable.
DATE Returns the current date.
ERRORLEVEL Returns the error code of the most recently used command. A non zero value usually indicates an error.
HOMEDRIVE Returns which local workstation drive letter is connected to the user’s home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.
HOMEPATH Returns the full path of the user’s home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.
HOMESHARE Returns the network path to the user’s shared home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.
LOGONSERVER Returns the name of the domain controller that validated the current logon session.
NUMBER_OF_PROCESSORS Specifies the number of processors installed on the computer.
OS Returns the operating system name.
PATH Specifies the search path for executable files.
PATHEXT Returns a list of the file extensions that the operating system considers to be executable.
PROCESSOR_ARCHITECTURE Returns the chip architecture of the processor. Values: x86, IA64.
PROCESSOR_IDENTIFIER Returns a description of the processor.
PROCESSOR_LEVEL Returns the model number of the processor installed on the computer.
PROCESSOR_REVISION Returns the revision number of the processor.
PROMPT Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.
RANDOM Returns a random decimal number between 0 and 32767. Generated by Cmd.exe.
SYSTEMDRIVE Returns the drive containing the Windows XP root directory (that is, the system root).
SYSTEMROOT Returns the location of the Windows XP root directory.
TEMP and TMP Returns the default temporary directories that are used by applications available to users who are currently logged on. Some applications require TEMP and others require TMP.
TIME Returns the current time.
USERDOMAIN Returns the name of the domain that contains the user’s account.
USERNAME Returns the name of the user who is currently logged on.
USERPROFILE Returns the location of the profile for the current user.
WINDIR Returns the location of the operating system directory.