/ Forums / Advansys Formativ / Creating Solutions with Formativ / Environ function in Applet

  • Creator
    Topic
  • #3977
    Anonymous

    Is it possible to use the Environ VB function in an Applet to gain access to the Path environment variable on a machine? It returns an empty string, even though the setting is present.

    Thank You

    John Hajjar
    IntelliReach Corporation

  • Author
    Replies
  • #6758
    Support 1
    Participant

    Unfortunately it is not possible to call the Environ function in an applet. However it is possible to access environment variables using the Windows scripting host. The following sample code reads all environment variables:

    '-------------------------------------------------------------------------------
    ' Read environment variables
    ' Link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshshell.asp
    '-------------------------------------------------------------------------------
     
    Sub Main(Client, GWEvent)
     
     dim item
     dim objEnv
     dim iMessage
     dim oWshShell
     
     Set oWshShell = CreateObject ("WScript.Shell")
     
     if oWshShell is nothing then
       exit sub
     end if
     
     ' Get the collection using the Environment property
     
     Set objEnv = oWshShell.Environment("Process")
     if objEnv is nothing then
       exit sub
     end if
     
    
     iMessage = "Environment variables" + vbcrlf + vbcrlf
     
     ' Read environment variables
     For Each item In objEnv
       iMessage = iMessage & vbcrlf & item
     Next
     
    
     msgbox iMessage
     
     set objEnv = nothing
     set oWshShell = nothing
     
    end Sub

    Advansys Support

    #6759
    Anonymous

    Great, that works. Thanks for the informative and timely response.

    Thank You
    John Hajjar
    IntelliReach Corporation

    #6757
    Support 1
    Participant

    Always happy to help. Thank you for the feedback.

    Advansys Support

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.