Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Windows username in a legacy (not WebExtensions) Firefox add-on?

Tags:

I am working a Firefox add-on (which is written in JavaScript) and need to determine the Windows user currently logged on. Is there a way to do this?

like image 335
cwhiii Avatar asked Jun 03 '10 18:06

cwhiii


1 Answers

This does the trick on Windows:

function getUser() {    return Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('USERNAME'); }       
like image 56
cwhiii Avatar answered Oct 07 '22 17:10

cwhiii