[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Get Computer Name

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
Entropy
Asked:
Entropy
  • 5
  • 3
  • 2
  • +3
1 Solution
 
robbertCommented:
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
 
Maxim10553Commented:
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
 
cybermoonlightCommented:
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
Independent Software Vendors: 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!

 
cybermoonlightCommented:
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
 
AzraSoundCommented:
>>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
 
clockwatcherCommented:
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
 
Maxim10553Commented:
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
 
cybermoonlightCommented:
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
 
EntropyAuthor Commented:
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
 
EntropyAuthor Commented:
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
 
EntropyAuthor Commented:
OK I figured out how to get it into the field...  this might just work.
0
 
EntropyAuthor Commented:
<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
 
AzraSoundCommented:
just keep us informed...sorry i didnt respond earlier, i was in an all day meeting
0
 
EntropyAuthor Commented:
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.

  • 5
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now