How to get the account username using MATLAB?
280 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chuck
am 21 Feb. 2016
Bearbeitet: Francisco Sacchetti
am 12 Okt. 2022
I am talking about the username, not the host or computer name. For instance, if you are working on Google Drive, your Drive folder will be under C://users/USERNAME. I am talking about that USERNAME part. :)
1 Kommentar
Ramnath Natarajan
am 19 Jul. 2022
If u run command prompt (windows button + R ------> type 'cmd' and press 'Enter'), the default command line shows the username (image below)
Akzeptierte Antwort
Chuck
am 21 Feb. 2016
Bearbeitet: Chuck
am 21 Feb. 2016
4 Kommentare
Walter Roberson
am 29 Mär. 2019
Which operating system, Ram? The solution for Windows is likely to be quite different than Linux or Mac.
Walter Roberson
am 29 Mär. 2019
Some of the techniques for Windows are described at https://stackoverflow.com/questions/7809648/get-display-name-of-current-windows-domain-user-from-a-command-prompt
Note that the solutions might be different for network login situations.
See also the .net approach https://www.codeproject.com/Articles/42282/Get-a-User-s-Full-Name
For Mac it looks like you could use
[status, fullname] = system('id -F')
but watch out as it will include line terminator
Weitere Antworten (2)
Image Analyst
am 21 Feb. 2016
To get the folder, you can use
userProfile = getenv('USERPROFILE');
2 Kommentare
Ashish Sheikh
am 16 Mär. 2020
I guess this is for Windows .. Do you by chance know how to get the userprofile on linux and mac ?
Walter Roberson
am 16 Mär. 2020
Mac and Linux do not have user profile. See https://www.mathworks.com/matlabcentral/answers/269214-how-to-get-the-account-username-using-matlab#comment_344298
Eran
am 20 Jan. 2022
Bearbeitet: Image Analyst
am 19 Jul. 2022
userName = char(java.lang.System.getProperty('user.name'))
4 Kommentare
Steven Lord
am 11 Okt. 2022
@Francisco Sacchetti What are you hoping or planning to do with that information in a web app?
Francisco Sacchetti
am 12 Okt. 2022
Bearbeitet: Francisco Sacchetti
am 12 Okt. 2022
I found a path:
- Enable SSL on the server. For more information, see Enable SSL.
- Enable authentication on the server. For more information, see Authentication.
And then you can use compiler.UserInfo() to get the infromation of the user.
I want to first to track who is using the app, also it will be nice to adapt the app depending on the users.
Siehe auch
Kategorien
Mehr zu Web Services finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!