SetUserEnv - sets the specified value into a user environment variable

Return to Introduction  Previous page  Next page

SetUserEnv(environment_variable,value )


environment_variableis a user environment variable name. The environment_variable may not contain embedded spaces. If the environment_variable does not already exist, it is created.
valuethe value assigned to environment_variable.


environment_variable and value may be TN3270 Plus variables.


The SetUserEnv command sets the value of a user environmental variable. This user environment variable is then accessible by external programs like PowerShell or VBScript. This makes it easy to pass information from a TN3270 Plus script to an external program. The user environment variables are visible in the "HKEY_CURRENT_USER\Environment" registry key.



SetUserEnv(Description,"Terminal Emulator")



Sample Scripts

The following TN3270 Plus sample script assigns a value to a user environment variable.

' SetUserEnvironmentVariable.txt

' Example that sets a user environment variable




The following VBscript accesses the user environment variable created in the TN3270 Plus script above.


' Windows VBScript to display a user environment variable


Dim objWSH

Dim objUserVariables


Set objWSH = CreateObject( "WScript.Shell" )

Set objUserVariables = objWSH.Environment("USER")



The following PowerShell script accesses the user environment variable created in the TN3270 Plus script above.

# DisplayUserEnvironmentVariable.ps1

# Windows PowerShell script to display a user environment variable


[environment]::GetEnvironmentVariable("ProductNumber", "User")


See Also:


Script Variables


Using the Scripting Language

TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.