Link to home
Start Free TrialLog in
Avatar of GRCHELPDESK
GRCHELPDESK

asked on

Using Javascript to grab the user's computer name

Hello all,

I'm trying to write a piece of javascript to get the client's computer name.
This is what I have so far...

<html>
<head>
<title>Javascript test</title>
<script language="JavaScript" type="text/javascript">
var strComputerName
{
var WshNetwork = new ActiveXObject("WScript.Network");
strComputerName = WshNetwork.ComputerName;
}

alert(strComputerName)

</script>
</head>

<body>

This should run the script

</body>
</html>

But I'm getting the follwoing error message: "Automation server can't create object."

Does anyone know what's up with that?
Thanks,
Maurice
ASKER CERTIFIED SOLUTION
Avatar of ThaSmartUno
ThaSmartUno

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GRCHELPDESK
GRCHELPDESK

ASKER

Hello ThaSmartUno,

Thanks for the response... even if it's a little depressing.  :)
I found the code here, and it seems to be working for them.
Unless I'm mis-understanding something...

https://www.experts-exchange.com/questions/21306539/retrieve-computer-name-with-javascript.html?query=javascript+"computer+name"&clearTAFilter=true
It works only on your own pc, if you run that from your browser located on your computer ...

on that Q they say "stand alone app" which im assuming means that it creates this web page on that computer and runs it.
So you're saying if I went to the server that's hosting this page, and ran it from there it would work?
Well... that's hardly ideal.

In your opinion, what's the way to accomplish this?  (assuming the exchange server isn't setup for reverse dns lookup)

Thanks!
Personally I have no idea what you could use.  I have had no reason to need to know a computer name so I can't really help you with that.  Sorry (I can search in little bit, but I'm just leaving work now so I won't be able to respond for about 30-40 min)
Thanks, I appreciate the effort.  If it can't be done, I'll have to figure something else out.  I guess I'll leave the question open for a bit in case someone has a work-around.

Thanks again!