Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get logged on username and drive letter?

Status
Not open for further replies.

davemarsh

Technical User
Feb 11, 2003
12
IN
Hi - I'm writing a small app that deletes some unwanted content in a folder.
But how do I get the users logged on name, for the right path? eg. 'C:\Documents and Settings\Administrator\folder\files'. Also their drive letter may not be 'C' - how could I check that?

Cheers
DM
 
Public strUser

strUser=Environ("username")

should give you the user logged on. Not sure about your second question though, hopefully another more experienced member will be be able to help you with that.
 
Try this this will loop through 100 Enrion variables
Code:
Private Sub Command1_Click()
    Dim i As Integer
    For i = 1 To 100
        Debug.Print Environ$(i)
    Next
End Sub

in the way of you are looking try this

Code:
Debug.Print Environ$("USERPROFILE")
'Will return
'C:\Documents and Settings\'UserName'
 
Thanks alot - that's just what i'm after.
 
However, do a keyword search in this forum on Environment Variables to see some views on their use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top