• Location of user profile folders (97sr2)

    Author
    Topic
    #400059

    I am building a small macro for use in applications testing, that will allow for easy recording of defects.
    I am stumped in one aspect however.

    On the client test machines I will have several users operating, and I want to be able to record user specific information so that it will persist for each user on subsequent logins on the test machine.
    I thought that adding a ini file to the winnt/profiles/user_logon_id/ folder tree would be an easy way to do this, however I cannot remember how to identify the user folders programmatically. That is how can I return a string that contains the path to the user folders in c:winntprofiles ??

    Can anyone help me out please.

    BTW – I cannot use the registry for this information due to corporate policies….

    Viewing 1 reply thread
    Author
    Replies
    • #777837

      Have you looked at the environment variables that are available under NT? I forget which ones may be specific to NT, but “USERPROFILE”, or some such variant, should be available. Then, you can use the function “ENVIRON()” to return the value stored in the variable.

      To see all the environment variables available, create a simple “For…Next” loop — using an index, not an object reference, i.e.

      Dim i as Integer

      For i = 1 to 200 ‘arbitrary limit; can’t retrieve actual limit from VBA
      Debug.Print Environ(i)
      Next i

      • #777849

        Even easier you can display a command window and type SET. This gives a list of all the environment variables, including USERPROFILE

        StuartR

      • #777850

        Even easier you can display a command window and type SET. This gives a list of all the environment variables, including USERPROFILE

        StuartR

      • #778011

        Ethan and Stuart,

        Thanks, that is exactly what I was after.

        Function UserProfilePath() As String
        UserProfilePath = Environ(“USERPROFILE”)
        End Function

      • #778012

        Ethan and Stuart,

        Thanks, that is exactly what I was after.

        Function UserProfilePath() As String
        UserProfilePath = Environ(“USERPROFILE”)
        End Function

    • #777838

      Have you looked at the environment variables that are available under NT? I forget which ones may be specific to NT, but “USERPROFILE”, or some such variant, should be available. Then, you can use the function “ENVIRON()” to return the value stored in the variable.

      To see all the environment variables available, create a simple “For…Next” loop — using an index, not an object reference, i.e.

      Dim i as Integer

      For i = 1 to 200 ‘arbitrary limit; can’t retrieve actual limit from VBA
      Debug.Print Environ(i)
      Next i

    Viewing 1 reply thread
    Reply To: Location of user profile folders (97sr2)

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

    Your information: