How can Windows 10 user account info be accessed through Matlab
Mostra commenti meno recenti
Our IT is currently transitioning from name based user accounts to numbered accounts. We have Matlab scripts which we use to generate documents that include user identification. The script is used the command:
username = getenv('USERNAME')
to find this information; however, this command returns the numbered account rather than an identifiable name. A proper name has been associated to the numbered account as seen in the O/S account settings. Windows can also associate additional information such as a picture with the account. What command should be used to get this information from the environment or operating system that is associated with current user running a Matlab session?
Risposta accettata
Più risposte (1)
Turlough Hughes
il 9 Feb 2022
[~,info] = system('whoami');
[~,info] = system('net user'); % another possibility
3 Commenti
Robert Heaton
il 9 Feb 2022
Turlough Hughes
il 9 Feb 2022
The system function runs O/S commands which is equivalent to doing it in command promt. I see what you mean now with the account settings username being different. I think the following should work (atleast it does on my computer):
[~,info] = system('wmic useraccount get FullName')
give it a try and let me know.
Robert Heaton
il 9 Feb 2022
Categorie
Scopri di più su Profile and Improve Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!