Envir$
System function.
The Envir$ function returns the value of an environment variable.
Syntax
var$=Envir$(<var_name$>)
Parameters
<var_name$>, string, name of an environment variable.
Return value
var$, string, value of the specified environment variable.
Remarks
envir$ can retrieve any Windows environment variables, but for the variables defined by the SET command, the SET command must have been done by WinTask in the actual session (see script example below).
Example
var$ = Envir$("mydir")
'returns in var$ "c:\test" if the statement " SET mydir = c:\test " has been executed
Example showing that envir$ can retrieve Windows environment variables plus only the variables which has been SET by the WinTask script :
shell("cmd")
var$="MYVARIABLE"
'The script sets up an environment variableusewindow("CMD.EXE|ConsoleWindowClass|")
sendkeys("set "+var$+" = VALUE")
sendkeys("<Enter>")
pause 1
sendkeys("cls<Enter>")
sendkeys("set "+var$)
sendkeys("<Enter>")
a$=capture$("CMD.EXE|ConsoleWindowClass|", 0, 1)
pos1=instr(a$,var$+" = ")
res$=mid$(a$,pos1,80)
msgbox(res$,64,"Capture in the Dos box")
'As you can see var$ is present in SET environment
'var$ is empty
a$=envir$(var$)
msgbox(var$+" : "+a$,64,"Variable retrieved using envir$ statement")
'Username is correct
a$=envir$("username")
msgbox("username : "+a$)
sendkeys("exit<Enter>")
pause 1
shell("cmd")
usewindow("CMD.EXE|ConsoleWindowClass|")
sendkeys("set "+var$)
sendkeys("<Enter>")
'As you can see, Var$ is not anymore in set environment as it's a new Dos box but username is still present
sendkeys("set username")
sendkeys("<Enter>")