Javascript get windows username.
In this tutorial,I will explain how to get windows username using javascript.

Example1:Retrieve Windows Username with JavaScript Scripting
    <script language="javascript">
        function GetWindowsUserName()
            var win = new ActiveXObject("WScript.Shell");
            var username=(win.ExpandEnvironmentStrings("%USERNAME%"));
<body OnLoad="GetWindowsUserName();">

Example2:Getting windows username in javascript

<script language="javascript" type="text/javascript">
var win = new ActiveXObject("WScript.Network");
alert (win.UserName);

Note:This code snippet will work only in Internet Explorer because Internet Explorer deals with ActiveX Controls.