• Getting NT/2000 Environment Variables

    Author
    Topic
    #355077

    This is an ongoing problem I keep hitting and have yet to find an answer. What I would like to do is get NT/2000 Environment variables like %userprofile% or %machinename% or %logonServer% and use them in VB and VBA applications. Has anyone got any ideas on how to get these?

    Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #523083

      Richard,

      You could try:
      environ(“userprofile”) or environ(“username”).

      I’m on Win95 at the moment, so I don’t have all values, so I don’t know if this will help.

      For a list of all Environ identifiers and values, try:

      Dim i As Integer
      For i = 1 To 20
        Debug.Print i; Environ(i)
      Next
      

      If “i=20” shows a value, increase the upper limit (I don’t know when to stop- the upper value, that is). That will show the environ names as well as values.

      • #523087

        Thanks! It works!
        I cant’t belive that this has been bugging me for this long and the answer was that simple!!

        Much appreciated!

        • #523090

          I was our site’s Word VBA guru for a long time- and it’s one of our LAN people who showed me that.

          Mind you, if there’s the faintest possibility that your application will be hosted outside a WinNT environment, look for an API solution. There’s posts in the forum to help you with that. Somewhere.

          • #523091

            Fortunatly i’m working on programs for a (Hopefully) standard desktop enviroment, but I do see your point. I was persuing the ADSI option which apparently would work in a NT4 Domain enviroment.

      • #1105080

        I’ve just received a PM that this helped somebody today.

        That’s the power of a community like this. Something seven years old can still be of use. To somebody.

        And I’m not even in IT any more.

        • #1105096

          >>”And I’m not even in IT any more”
          and you’ve lost your chef’s hat too, oddly! grin

    Viewing 0 reply threads
    Reply To: Getting NT/2000 Environment Variables

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: