Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get Computer Name

Posted on 2001-06-04
14
243 Views
Last Modified: 2010-05-18
I want to get the computer name of the client machine and post it to the page as a form value. I would like to do this either automatically when the page loads or after a button or link is clicked.

This is on an intranet, and won't be used on the internet at any point.

I thought that:
%=Request.Cookies("Preferences")("Computer_Name")%
or
%=Request.ServerVariables("REMOTE_HOST")%

would do it but they are not it...


I did a search but the search just sat there several times so I guess I will just ask.

All machines are running IE 4.x or IE 5.x and WinNT.

Thanks In Advance for any help.

(This does not necessarily have to be ASP depending on what other solutions entail.)
0
Comment
Question by:Entropy
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 15

Expert Comment

by:robbert
ID: 6153191
The only ways are a) asking the user (and saving that to a cookie) or b) writing a client-side ActiveX control (requires custom IE security settings).
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6153918
couldnt you grab the IP of the computer with Request.ServerVariables("REMOTE_HOST"), store the IP to a variable and pass it to dll acting as a wrapper that takes an IP as its sole parameter and, using the Win API grabs the computer name from the IP(im sure there is a windows function that does this), and send it back to the calling ASP?
0
 
LVL 2

Expert Comment

by:cybermoonlight
ID: 6154294
I seriously doubt that this is possible..you cannot get the computer name from an IP..you can perhaps resolve a netbios add. i'm not sure..but no way can u get com name from ip
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:cybermoonlight
ID: 6154303
oops..i may have been a bit hasty..didn't see this was on an intranet..
Also maxim..your comment is exactly what robbert means..isn't it?
on't know how big your intanet is but perhaps you could have static IPs such as .1 for mach1 .2 for mach2, etc..
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 300 total points
ID: 6154482
>>writing a client-side ActiveX control

you can use WSH client-side...its an activeX solution, but you are spared the task of writing your own control:


<html>
<script language="VBScript">
Sub GetCompName()
     Dim wshObj
     Set wshObj = CreateObject("WScript.Network")
     MsgBox wshObj.ComputerName
End Sub
</script>
<body onload="GetCompName()"
</body>
</html>
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 6154511
The rules are often different on an intranet.  Pick an IP of a machine on your intranet and try the following from the commandline of your webserver:

  nbtstat -A <IP address>

Odds are good that you'll get the remote machine's name table.  If you do, then it's a simple matter to use AspEXEC (http://www.serverobjects.com/products.htm#free) to do something like:

<%
Set myExecutable = Server.CreateObject("ASPExec.Execute")
 myExecutable.Application = "nbtstat -A " & request.servervariables("REMOTE_ADDR")
 myExecutable.ShowWindow = False
 Response.Write "Executing " & myExecutable.Application & "<br>"
 strResult = myExecutable.ExecuteDosApp
 lines = split(strResult, chr(13))
 for i = lbound(lines) to ubound(lines)
   if lines(i) <> "" then response.write lines(i) & "<BR>"
   locmatch = instr(1, lines(i), "<20>")
   if locmatch > 1 then machinename = trim(left(lines(i), locmatch - 1))
 next
%>
<hr>Machine Name: <%=machinename%>
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6156175
Also maxim..your comment is exactly what robbert means..isn't it?-> no, my idea does not involve any client-side ActiveX controls, the code and dll are both executed server-side, i think you could do it this way
0
 
LVL 2

Expert Comment

by:cybermoonlight
ID: 6156186
yeah..okay i see what you mean..but i doubt it's possible. Client side activex..will work..but server side..no way
correct me if i'm wrong
0
 

Author Comment

by:Entropy
ID: 6157693
Azrasound

That worked on my machine but will require some editing of the ActiveX permissions possibly.  We are talking a whole department here too so that could mean hundreds.  Still viable... I may be able to get around it, it does prompt so... I will play with it and let you know.

Someone asked how big the network was for static addresses... we have about 60K Employees so that would not be feasible.  I should have mentioned the scope so that machine level changes could be put into perspective sorry about that.

Clockwatcher... I couldn't get your script to work... which could be operator malfunction but I do know the nbtstat command will work... but it gives 6 registered responses, which I think could effect the outcome.

Thanks all... so far. :)
0
 

Author Comment

by:Entropy
ID: 6157706
Also, Azrasound...

 How could I post that out to a value in the page.  I need it to appear in a form and then obviously be passed on. Worst comes to worse they can type it from the box... but that leaves room for user error.
0
 

Author Comment

by:Entropy
ID: 6157990
OK I figured out how to get it into the field...  this might just work.
0
 

Author Comment

by:Entropy
ID: 6158001
<SCRIPT Language="VBScript">
Function GetCompName()
    Dim GetComp
    Set GetComp = CreateObject("WScript.Network")
    document.RequestForm.ComputerName.value = GetComp.ComputerName
End Function
</SCRIPT>


Is what I am using now... I have to do some testing but I think this is the simplest and best way.  If all goes well I think you got it Azrasound thanks.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6158126
just keep us informed...sorry i didnt respond earlier, i was in an all day meeting
0
 

Author Comment

by:Entropy
ID: 6159879
Well, it works, I just have to add a line in there that says "Click Yes on the Security Box" at least until the next image comes out and I can have the security settings changed to enable instead of prompt.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Displaying number of records depdning on table contents - classic asp 13 44
Time/Date Query 11 42
Executing a script on a timer online 5 20
CREATE DATABASE 3 28
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question