The following will work, but probably only on IE (with an appropriate ActiveX warning)
<html>
<head>
<script language="javascript">
function GetUserName()
{
var wshell = new ActiveXObject("WScript.Shell");
alert(wshell.ExpandEnvironmentStrings("%USERNAME%"));
}
</script>
</head>
<body onload="GetUserName();">
</body>
</html>