Function Setenv() Foundation
Sets the contents of an operating system environment variable.
Setenv( <cSetVar>, <cValue> ) --> lSuccess
The function returns .T. (true) if the environment variable could be set, otherwise it returns .F. (false).
The function Setenv() is used to set new or alter current environment variables of the active process. Note that it cannot be used to change the environment of other processes. However, if a new process is spawned using the RunShell() function, the new process inherits the environment variables of the active process. Therefore, Setenv() is suitable to define the environment variables for a new process.
// The example demonstrates how to alter an
// existing environment variable.
PROCEDURE Main
LOCAL cPath := GetEnv( "PATH" )
IF .NOT. Right(cPath,1) == ";"
cPath += ";"
ENDIF
? cPath // result: C:\WINNT;
cPath += "C:\BIN;"
? Setenv( "PATH", cPath ) // result: .T.
? Getenv( "PATH" ) // result: C:\WINNT;C:\BIN;
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.