Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get OS Win 7 username Javascript

Tags:

javascript

api

Is it possible to get Windows username and PCName with Javascript in browsers IE, Chrome, Firefox, Opera?

like image 345
Airat Suleimanov Avatar asked Jan 10 '12 11:01

Airat Suleimanov


2 Answers

No. That sort of information is not exposed to the javascript engine in the browser.

like image 84
Mike Thomsen Avatar answered Nov 15 '22 10:11

Mike Thomsen


i'd really wish this wouldn't be possible, but sadly it is (or was). i don't know for sure if this still works on Win7 and with current browser-versions, but in the past you could do this...

Internet Explorer

function getUsr() {
   var wshell = new ActiveXObject("WScript.Shell");
   return wshell.ExpandEnvironmentStrings("%USERNAME%");
}
like image 27
oezi Avatar answered Nov 15 '22 08:11

oezi