UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Closed TopicStart new topic
> Environ Function - List of environment variable    
 
   
MicroE
post Apr 28 2005, 12:50 PM
Post#1


UtterAccess VIP
Posts: 4,034
Joined: 22-February 05
From: NY - USA


Provided is a list of common environment variables. Also, code is provided (courtesy of Rob Cooper - Microsoft Access Team) that loops to enumerate custom environment variables.
LLUSERSPROFILE
APPDATA
AVENGINE
CLIENTNAME
CommonProgramFiles
COMPUTERNAME
ComSpec
FP_NO_HOST_CHECK
HOMEDRIVE
HOMEPATH
INCLUDE
INOCULAN
LIB
LOGONSERVER
NUMBER_OF_PROCESSORS
OS
Path
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
ProgramFiles
SESSIONNAME
SystemDrive
SystemRoot
TEMP
TMP
USERDOMAIN
USERNAME
USERPROFILE
VS71COMNTOOLS
WecVersionForRosebud.FF0
windir
Courtesy of Rob Cooper
Custom environment variables could also be created and vary by system. You can write a loop to enumerate them:
CODE
Sub test()
    Dim i As Integer
    Dim stEnviron As String
    For i = 1 To 50
        ' get the environment variable
        stEnviron = Environ(i)
        ' see if there is a variable set
        If Len(stEnviron) > 0 Then
            Debug.Print i, Environ(i)
        Else
            Exit For
        End If
    Next
End Sub

Otypically use 50 for the loop because I've always had less than that, but you could certainly increase it if needed. This code will print out the name and value of the environment variables on a given machine.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 09:36 PM