How to get user homepath?

46 Ansichten (letzte 30 Tage)
Wictor Oliveira
Wictor Oliveira am 1 Sep. 2022
Kommentiert: Wictor Oliveira am 6 Sep. 2022
I want to get the user homepath in windows, the same as when I type '%homepath%' in the file explorer.
Example: 'C:\Users\USERNAME'
I am currently using this:
home_path = strrep(userpath,'Documents\MATLAB','')
but I'm afraid it might not work for all users depending on the way they installed matlab.
Is there a less 'hardcoded' way to get the user homepath in windows?

Akzeptierte Antwort

Steven Lord
Steven Lord am 1 Sep. 2022
Does getenv do what you want?
  1 Kommentar
Wictor Oliveira
Wictor Oliveira am 6 Sep. 2022
Thank you! That's an improvement.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by