|
Environment Property |
|
Description
Returns a collection of all the environment variables.
PowerBASIC Syntax
Arguments
Return Value
IDispatch. Reference to a IWshEnvironment interface.
Remarks
The Environment property contains the WshEnvironment object (a collection of environment variables). If vType is supplied, it specifies where the environment variable resides with possible values of System, User, Volatile, or Process. If vType is not supplied, the Environment property returns different environment variable types depending on the operating system.
Note For Windows95/98/Me, only one strType is permitted — Process.
The following table lists some of the variables that are provided with the Windows operating system. Scripts can access environment variables that have been set by other applications.
Note None of the following variables are available from the Volatile type.
Example [PowerBASIC]
#INCLUDE "WSHOM.INC"
DIM pWsh AS IWshShell DIM pWshEnv AS IWshEnvironment DIM nCount AS LONG DIM pUnk AS IUnknown DIM pEnum AS IEnumVARIANT DIM IID_IEnumVARIANT AS GUID DIM i AS LONG DIM celtFetched AS LONG DIM vValue AS VARIANT
' Create an instance of Windows Script Host pWsh = NEWCOM "WScript.Shell" ' Get a reference to environment collection pWshEnv = pWsh.Environment ' Get the number of objects in the collection nCount = pWshEnv.Count ' Get a reference to the collection's enumerator pUnk = pWshEnv.NewEnum_ pEnum = pUnk FOR i = 0 TO nCount - 1 pEnum.Next 1, vValue, celtFetched IF celtFetched = 0 THEN EXIT FOR STDOUT VARIANT$(vValue) NEXT
Example [PowerBASIC]
#INCLUDE "WSHOM.INC"
LOCAL pWsh AS IWshShell LOCAL pWshEnv AS IWshEnvironment LOCAL vType AS VARIANT
pWsh = NEWCOM "WScript.Shell" ' Get a reference to environment collection vType = "SYSTEM" pWshEnv = pWsh.Environment(vType) STDOUT ACODE$(pWshEnv.Item(UCODE$("NUMBER_OF_PROCESSORS")))
|
