This is a VBScript I put together a while back. It works on XP, but hasn't been tested on Windows 7.
Code:
' Ignore any errors
On Error Resume Next
' define some constants
Const HKEY_LOCAL_MACHINE = &H80000002
Const STR_GUID_PATH = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileGuid"
Const ROOT_PROFILE_PATH = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\"
Const SID_STRING = "SidString"
' some variables
strProfiles = ""
' Create a shell
Set WSHShell = CreateObject("WScript.Shell")
' Open the Registry
Set objRegistry=GetObject("winmgmts:\\.\root\default:StdRegProv")
' Extract the ProfileGUID entries from the registry returned in arrGUIDs
objRegistry.EnumKey HKEY_LOCAL_MACHINE, STR_GUID_PATH, arrGUIDs
' Process each of the entries in the ProfileGUID
For Each objSubkey In arrGUIDs
' Extract the SID from the GUID entry
strRegPath = STR_GUID_PATH & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE, strRegPath, SID_STRING, sidString
' Extract the profile path from the ProfileList sub tree in the registry relating to the current GUID / SID
ProfileRegPath = ROOT_PROFILE_PATH & sidString
RegKey = ProfileRegPath & "\ProfileImagePath"
profilePath = WSHShell.RegRead (regkey)
' Replace %systemdrive% with "c:"
profilePath = replace(profilePath,"%SystemDrive%","C:")
' Extract username from profilePath
userName = Right(profilePath, len(profilePath)-InStrRev(profilePath,"\"))
' Create an array containing all the extracted info
strProfiles = strProfiles & Username & vbCrLf & "GUID: " & objSubkey & vbCrLf & "SID: " & sidString & vbCrLf & "Path: " & profilePath & vbCrLf & vbCrLf
Next
Wscript.echo(strProfiles)