Environment.Item

Introduced

v3.5

Description

Sets or returns the String value of system environment variable.

Note: You cannot use this property to set an environment variable with the Python scripting language because the win32 extensions do not support setting parameterized properties. Use the Environment.SetItem method instead after generating Python COM support for XSIUtils as specified below:

You can use python 2.3 or later and win32 extension 1.55 or later to generate Python COM support for the XSIUtils type library. This creates a SetItem( name, value ) method which allows you to set the item property (see Environment.SetItem).

You can generate Python COM support for XSIUtils by running the makepy.py utility on the XSIUtils type library. This will generate .py stubs containing descriptions of the object's methods and properties supported by the XSIUtils module.

C# Syntax

// get accessor
String IEnvironment.get_Item( String in_bstrName );
// set accessor
IEnvironment.set_Item( String in_bstrName, String pVal );

Examples

1. VBScript Example

' how to create and set a new environment variable
XSIUtils.Environment("MY_HOME") = XSIUtils.Environment.Item("XSI_USERHOME")
LogMessage( "my home folder: " + XSIUtils.Environment.Item("MY_HOME") )

2. Python Example

# This example illustrates how to create and set a new environment variable.
# Note that the SetItem method can only be used if python 2.3 or later 
# and win32 extension 1.55 or later are installed and the generated 
# Python COM Support exists for the XSIUtils library. 
# The Python COM support for the XSIUtils can be generated by running the makepy.py 
# utility on the XSIUtils type library. This will generated .py stubs contain
# descriptions of the object's methods and properties supported by the module.
import sys
Application.LogMessage( "Python Version " + sys.version )
if sys.version_info >= (2, 3):
	XSIUtils.Environment.SetItem( "MY_HOME", XSIUtils.Environment.Item("XSI_USERHOME") )
	Application.LogMessage( XSIUtils.Environment.Item("MY_HOME") )
else:
	Application.LogMessage( "Can't use Environment.SetItem with this version" )

See Also

Environment.SetItem