I think you should not use user's name to obtain a path to user's profile directory. The directory name can be different than user's name - for example in case user name hsa been changed after the profile was created or if there is a user name conflict (a local user has the same username as a domain user).
You can do a dir
of AppData\Roaming
for each subdirectory of C:\Users
using the following syntax:
for /d %A in (C:\Users\*) do if exist %A\AppData\Roaming dir %A\AppData\Roaming
But again this solution will omit any user profiles that are stored outside C:\Users.
To do a dir
of AppData\Roaming
directory of each user profile, you can get the paths of user profiles from registry:
for /f "tokens=3" %A in ('reg query "HKLM\Software\Microsoft\WindowsN T\CurrentVersion\ProfileList" /s /v ProfileImagePath ^| find "REG_EXPAND_SZ"') do @dir %A\AppData\Roaming
If you want to use these commands in a script, use double percent signs (%%A).
To learn more about for
command type for /?