Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get Computer Name

Posted on 2001-06-04
14
Medium Priority
?
251 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
[X]
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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1200 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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 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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 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