Solved

Get Computer Name

Posted on 2001-06-04
14
244 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Time Conversions...both ways 2 24
Cannot open file from ASP if user is "logged in" 13 34
Writing comments on <p></P> or paragraph 2 23
ASP get fieds value 2 22
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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