Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting NT Username 1

Status
Not open for further replies.

Coogan

Programmer
Jun 21, 2004
38
GB
Hi folks,

Hope you can help me on this.

What I am trying to find out is if it is possible to get an NT username through javascript.

The codeing that I have found so far does not seem to work.

The code that i have is:

Code:
<script language="javascript">
function getdata()
{
var username = System.getProperty("user.name");
username = username + ".htm";
window.open(username,'null','menubar=no,width=500,height=600',false);
}
</script>

<body>
<form name="form1" method="post" action="">
  <input name="Button" type="button" onClick="getdata()" value="Get Stats">
</form>
</body>

When i run this code i get the error "System is undefined".

Any help would be greatly appreciated.

Thanks

Martin
 
That'd only work for a Java applet I think. If you get permissions, you can do this instead:

var WSHShell = new ActiveXObject('WScript.Shell');
var RegLocate;
RegLocate = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Logon User Name";
alert(WSHShell.RegRead(RegLocate));

Of course that will only work on IE/Win ;-)
 
Thanks Ivanv.

This works a treat on my standalone machine. Will have to wait to Monday to see if I can get it working on an NT network.

Thanks again.

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top