File Exchange

image thumbnail

Get user home directory

version (446 Bytes) by Sven Probst
get the user's home directory platform independent


Updated 10 Aug 2007

No License

GETUSERDIR returns the user home directory using the registry on windows systems and using Java on non windows systems as a string

As I am not familiar with non windows operating systems please give me information about incompatibilities - I rely on JAVA in this function

Comments and Ratings (9)


Yona (view profile)

very useful

David Young


David (view profile)


David (view profile)



Eric (view profile)

Martin O'Reilly

Nice bit of code - just what I was looking for.

@ andy a: getenv('USERPROFILE') gets the root of your Windows profile. By default your "My Documents" folder will be directly under this root. Fowever, getenv('USERPROFILE') will not get your "My Documents" folder if you have changed it from the default (e.g. to another partition to separate data and operating system files).

andy a

Why not just this

if ispc; userdir= getenv('USERPROFILE');
else; userdir= getenv('HOME');

Javier Lopez


MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor