1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Windows Environment Variables in VB

Discussion in 'Visual Basic [VB]' started by shabbir, Nov 24, 2004.

  1. shabbir

    shabbir Administrator Staff Member

    Visual Basic 6 provides a function called Environ through which you can get all the environment variables available. It takes string parameter which is name of the Environment variable and returns its value.

    The Valid Environment strings are

    ALLUSERSPROFILE
    APPDATA
    CI_HOLOS_CLI
    CLIENTNAME
    CommonProgramFiles
    COMPUTERNAME
    ComSpec
    FP_NO_HOST_CHECK
    HOMEDRIVE
    HOMEPATH
    include
    JAVA_HOME
    lib
    LOGONSERVER
    MSDevDir
    NUMBER_OF_PROCESSORS
    OS
    Path
    PATHEXT
    PROCESSOR_ARCHITECTURE
    PROCESSOR_IDENTIFIER
    PROCESSOR_LEVEL
    PROCESSOR_REVISION
    ProgramFiles
    SESSIONNAME
    SystemDrive
    SystemRoot
    TEMP
    TMP
    USERDNSDOMAIN
    USERDOMAIN
    USERNAME
    USERPROFILE
    windir

    The following code will help you get all the Environment variables on your system
    Code:
      Dim i as Integer
      Text1.Text = ""
      i = 1
      While Environ$(i) <> ""
      	Text1.Text = Text1.Text + Mid(Environ$(i), 1, InStr(1, Environ(i), "=") - 1) + vbNewLine
      	i = i + 1
      Wend
      
     
  2. coderzone

    coderzone Super Moderator

    Really helpful. I just needed the JAVA_HOME to run and compile the code.
     

Share This Page