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

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

Get client's computer name and it's assets

Is there a way to retrieve client's machine name along with all of it's asset via ASP or ActiveX? This is for internal use (intranet).
Assets would include: Inventory hardware, software and user information

Thanks!
0
dellon
Asked:
dellon
  • 28
  • 12
  • 6
  • +2
1 Solution
 
GhasanoCommented:
Take a look at Request.ServerVariables("REMOTE_HOST"). All bets are off if
you're using a proxy.
0
 
alorentzCommented:
Computer name like this:

pcname  = request.servervariables("REMOTE_HOST")

the other stuff is usually done via startup network script, or installed asset manager software....not via ASP
0
 
dellonAuthor Commented:
Request.ServerVariables("REMOTE_HOST") would only give me the address of the server.
I would like to have the client's information that landed on an intranet page.
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!

 
alorentzCommented:
knew i should have refreshed.
0
 
GhasanoCommented:
<TABLE>
      <TR>
           <TD>
                <B>Server Varriable</B>
           </TD>
           <TD>
                <B>Value</B>
           </TD>
      </TR>

      <% For Each name In Request.ServerVariables %>
      <TR>
           <TD>
                <%= name %>
           </TD>
           <TD>
                <%= Request.ServerVariables(name) %>
           </TD>
      </TR>
      <% Next %>
</TABLE>
0
 
alorentzCommented:
Here are the 3 options:

REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
0
 
alorentzCommented:
If none of those 3 get you the name of the machine, then you probably can't get it.
0
 
alorentzCommented:
0
 
dellonAuthor Commented:
yes, sorry.. REMOTE_HOST gives the ip address of the Client visiting the server.
0
 
dellonAuthor Commented:
ServerVariables doesn't give me what I need.
Maybe an ActiveX control that scans the client's machine? hmm...
0
 
alorentzCommented:
Yes, but you probably won't find that here.  This is for ASP code...not creating ActiveX controls.  They make software for that sort of thing.
0
 
NovoNordiskCommented:
Yes an example is Centennial - www.centennial-software.com or co.uk
0
 
GhasanoCommented:
Try this to get the computer name. However it gives a very ugly dialog box saying ActiveX control is used!
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
       var wshNetwork = new ActiveXObject("WScript.Network");
    alert(wshNetwork.ComputerName);
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
0
 
GhasanoCommented:
I don't think there is a way to get the username and computername without creating an ActiveX object (the ugly dialog box). Allowing the dialog box, you can retrieve the information this way:

Dim objNet
On Error Resume Next 'In case we fail to create object then display our custom error
Set objNet = CreateObject("WScript.NetWork")
If  Err.Number <> 0 Then                'If error occured then display notice
     MsgBox "Don't be Shy." & vbCRLF &_               "Do not press ""No"" If your browser warns you."
     Document.Location = "UserInfo.html"                                               'Place the Name of the document.
                                     'It will display again
End if
     
Dim strInfo
strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain
MsgBox strInfo
     
Set objNet = Nothing                    'Destroy the Object to free the Memory
0
 
GhasanoCommented:
Here's a poor-man's method that works well in an intranet environment. It
pings the remote_addr using the -a switch which asks that ping.exe return
the hostname, if it can be reverse-resolved:

<%
Dim sIP
Dim oShell, oExec, sCommand, sOutput
sIP = Request.ServerVariables("REMOTE_ADDR")
''watch for line wrap - begin
sCommand = "%comspec% /c @echo off & for /f ""tokens=2"" %q in ('ping -n
1 -a " & sIP & "^|find /i ""pinging""') do echo %q"
''watch for line wrap - end
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(sCommand)
sOutput = oExec.StdOut.ReadAll
Set oExec = Nothing
Set oShell = Nothing
Response.WRite sOutput
%>
0
 
GhasanoCommented:
Check the NTFS permissions on %windir%\system32\ping.exe. Oddly, on my
computer (XP SP1), ping.exe has my IUSR account specifically denied. When I
run this on a W2K Server, however, all is fine.

Also check the permissions on your cmd.exe (%comspec%). Permissions are
explicitely denied on this file as well.
0
 
GhasanoCommented:
if you tried all and doesn't give you what you need then ...
you can't, and if you could, you would have found a security hole and it would be fixed quickly.

For the information you want to have, you need permission from the user to get it. Either just ask it in a form, or ask permission to install some ActiveX or so on the client that will do the job.



0
 
dellonAuthor Commented:
I can get the username just fine. Computer name is the bottleneck.. well along with asset retrieval.

Ghasano, your script returns an error:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/test.asp, line 6, column 49

which is this line:
     MsgBox "Don't be Shy." & vbCRLF &_               "Do not press ""No"" If your browser warns you."
0
 
dellonAuthor Commented:
Ghasano, your last script works. What's weird is that it retrieves my old computer name, eventhough it no longer exist in the AD.
0
 
GhasanoCommented:
try this :
<%
Dim objNet
On Error Resume Next 'In case we fail to create object then display our custom error
Set objNet = CreateObject("WScript.NetWork")
If  Err.Number <> 0 Then                'If error occured then display notice
     Response.Write "Don't be Shy." & vbCRLF &_              
     Document.Location = "UserInfo.html"                    'Place the Name of the document.
                                     'It will display again
End if
     
Dim strInfo
strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain
response.Write strInfo
     
Set objNet = Nothing                    'Destroy the Object to free the Memory
%>
0
 
dellonAuthor Commented:
That returns the server's username and computername.

I can use your previous script just fine, but where is it retrieving my last computer name from...?
And regarding the retrieval of computer assets such as software installed, hardware configuration, etc, I guess that needed to be done via ActiveX control?
0
 
GhasanoCommented:
alright let me see it
0
 
GhasanoCommented:
you can retrieve motherboard information:
......................................
<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
7.1">
            <meta  name="vs_targetSchema"
 content="http://schemas.microsoft.com/intellisense/ie5">
      <script  id=clientEventHandlersJS  language=javascript>
<!--

function Button1_onclick() {
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.HostingBoard + "</td>");
            document.write("<td>" + p.Manufacturer + "</td>");
            document.write("<td>" + p.PoweredOn + "</td>");
            document.write("<td>" + p.Product + "</td>");
            document.write("<td>" + p.SerialNumber + "</td>");
            document.write("<td>" + p.Version + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

//-->
</script>
</head>
      <body>
            <INPUT  id="Button1"  type="button"  value="Button"
 name="Button1"  language=javascript  onclick="return Button1_onclick()">
      </body>
</html>
0
 
GhasanoCommented:
How to list all the information related to processors using JavaScript
(Page 2 of 6 )



Now, let us try to develop a simple script (JavaScript) which shows the technique for retrieving the information related to each processor on a web page. The entire code for the sample is as follows:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
7.1">
            <meta  name="vs_targetSchema"
 content="http://schemas.microsoft.com/intellisense/ie5">
      <script  id=clientEventHandlersJS  language=javascript>
<!--

function Button1_onclick() {
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.Caption + "</td>");
            document.write("<td>" + p.DeviceID + "</td>");
            document.write("<td>" + p.Name + "</td>");
            document.write("<td>" + p.CpuStatus + "</td>");
            document.write("<td>" + p.Availability + "</td>");
            document.write("<td>" + p.Level + "</td>");
            document.write("<td>" + p.ProcessorID + "</td>");
            document.write("<td>" + p.SystemName + "</td>");
            document.write("<td>" + p.ProcessorType + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

//-->
</script>
</head>
      <body>
            <INPUT  id="Button1"  type="button"  value="Button"
 name="Button1"  language=javascript  onclick="return Button1_onclick()">
      </body>
</html>
0
 
GhasanoCommented:
The above code would automatically list all the processors along with their IDs and other technical information.  To retrieve processor information, I used the built-in class “Win32_Processor.”  The class internally has a lot of properties, methods and events.  But in the above example we concentrated only on the properties which are considered important (related to the “Win32_Processor” class).

The “for” loop I used in the above code iterates for every processor present in the system and finally retrieves only the properties of that processor.  
0
 
dellonAuthor Commented:
hmm.. both page 1 and 2 of the scripts returns error:
Automation server can't create object.
0
 
GhasanoCommented:
which script ?
0
 
GhasanoCommented:
i tried on windows 2003 server enterprise and it works
0
 
GhasanoCommented:
What OS are you using? Is WMI installed?
http://www.microsoft.com/downloads/...&displaylang=en
0
 
JackOfPHCommented:
listening
0
 
dellonAuthor Commented:
Both script gives error I mentioned above when the button is pushed.

I'm running w2k on the server. Where can I check on WMI installation? Add/Remove Programs doesn't show any WMI Components available to install nor does any WMI appears in the list of installed programs.
0
 
GhasanoCommented:
To install the WMI Windows Installer Provider for Windows Server 2003, follow these steps:

1. Double-click Add/Remove Programs in the Control Panel.

2. Select Add/Remove Windows Components from the left-hand column.

3. Select Management & Monitoring Services in the list, then click Details.

4. Check WMI Windows Installer Provider and click OK.

5. Click Next to complete the installation.
0
 
GhasanoCommented:
This software package is already installed by default on Windows 2000 and Windows Millennium.
0
 
GhasanoCommented:
look at this url :
http://cwashington.netreach.net/depo/view.asp?Index=769
.............
Enumerate all installed software by querying the registry but you need WMI to do all of your thoughts
0
 
GhasanoCommented:
this is a JSCRIPT ...i posted 2 pages using javascript but with WMI control and it worked on my computer ..
i use windows 2003 enterprise server sp1
0
 
dellonAuthor Commented:
I'm on windows2000 server sp3.

My options under Management & Monitoring Services are:
Connection Manager Components
Network monitor Tools
Simple Network Management Protocol
0
 
GhasanoCommented:
enable IE's "Initialize and script ActiveX controls not marked as safe",
..........
Are you logged on as a regular user or administrator?
0
 
GhasanoCommented:
try to download windows 2000 server service pack 4
http://www.microsoft.com/windows2000/downloads/servicepacks/sp4/default.mspx
..............
what i knew that if you got this error that means wmi :
1- isn't installed correctly
2- not installed
3 - permission ( you must be logged as administrator )
also wmi is your needs to determine hardware information and software installed ...i posted scripts about software installed  ...
this error it occurs only on windows 2000 server so try to solve it by upgrading to sp4 ...you can test it on xp and i'm sure it works fine else security issues.. you can try to enable IE's "Initialize and script ActiveX controls not marked as safe",
0
 
GhasanoCommented:
good luck
0
 
dellonAuthor Commented:
Ghasano, you're the man.
Your suggestion to enable IE's "Initialize and script ActiveX controls not marked as safe" did it.

Is there any other information than the above, that I can retrieve out of a system?

Thanks a bunch!
0
 
GhasanoCommented:
latelly i was confused but i tried all different ways to solve ... anyway good luck
please read this thread again then you will finally have a best solution..
0
 
dellonAuthor Commented:
Your answer above says page 1 and 2 of 6... was just wondering if there's other information to retrieve.
Let me know if there are.. thanks!
0
 
GhasanoCommented:
retrieve keyboard information :
--------------------------------------
Now, let us try to develop a simple script (JavaScript) which shows the technique for retrieving the keyboard information on a web page. The entire code for the sample is as follows:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
7.1">
            <meta  name="vs_targetSchema"
 content="http://schemas.microsoft.com/intellisense/ie5">
      <script  id=clientEventHandlersJS  language=javascript>
<!--

function Button1_onclick() {
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.Description + "</td>");
            document.write("<td>" + p.Name + "</td>");
            document.write("<td>" + p.Status + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

//-->
</script>
</head>
      <body>
            <INPUT  id="Button1"  type="button"  value="Button"
 name="Button1"  language=javascript  onclick="return Button1_onclick()">
      </body>
</html>

The above code would automatically list all the information related to the keyboard.  To retrieve keyboard information, I used the built-in class “Win32_Keyboard.”  The class internally has a lot of properties, methods and events.  But in the above example we concentrated only on the properties “Description,” “Name” and “Status” (related to the “Win32_Keyboard” class).

The “for” loop I used in the above code iterates for every keyboard (usually only one) present in the system and finally retrieves only the properties of that keyboard.
0
 
GhasanoCommented:
Rretrieving the CD-ROM information on a web page. The entire code for the sample is as follows:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
7.1">
            <meta  name="vs_targetSchema"
 content="http://schemas.microsoft.com/intellisense/ie5">
      <script  id=clientEventHandlersJS  language=javascript>
<!--

function Button1_onclick() {
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM
Win32_FloppyDrive");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.Description + "</td>");
            document.write("<td>" + p.DeviceID + "</td>");
            document.write("<td>" + p.Status + "</td>");
            document.write("<td>" + p.Manufacuturer + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

//-->
</script>
</head>
      <body>
            <INPUT  id="Button1"  type="button"  value="Button"
 name="Button1"  language=javascript  onclick="return Button1_onclick()">
      </body>
</html>
0
 
GhasanoCommented:
listing the information of all on-board devices using JavaScript

retrieving the information of each on-board device on a web page. The entire code for the sample is as follows:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
7.1">
            <meta  name="vs_targetSchema"
 content="http://schemas.microsoft.com/intellisense/ie5">
      <script  id=clientEventHandlersJS  language=javascript>
<!--

function Button1_onclick() {
      var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM
Win32_OnBoardDevice");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.Description + "</td>");
            document.write("<td>" + p.DeviceType + "</td>");
            document.write("<td>" + p.Enabled + "</td>");
            document.write("<td>" + p.Tag + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

//-->
</script>
</head>
      <body>
            <INPUT  id="Button1"  type="button"  value="Button"
 name="Button1"  language=javascript  onclick="return Button1_onclick()">
      </body>
</html>

The above  code would automatically list all the devices (which are part of hardware) along with their descriptions, device types and other information.  To retrieve device information, I used the built-in class “Win32_OnBoardDevice.”  The class internally has a lot of properties, methods and events.  But, in the above example we concentrated only on the properties “Description,” “DeviceType,” “Enabled” and “Tag” (related to “Win32_OnBoardDevice” class).

In general, there will be many types of devices “OnBoard.”  The devices include Video, SCSI controller, Ethernet (especially for LAN), and so on.  The “DeviceType” property explains the type of device being represented.  The following is the table extracted from MSDN to provide you with an explanation of those values returned by “DeviceType.”

Value
 Meaning
 
1
 Other
 
2
 Unknown
 
3
 Video
 
4
 SCSI Controller
 
5
 Ethernet
 
6
 Token Ring
 
7
 Sound
 

The “for” loop I used in the above code iterates for every device present in the system and finally retrieves only the properties of that device.  Please be aware that your system may become unresponsive when using this script as it will take a while to retrieve all of the hardware information.
0
 
dellonAuthor Commented:
Thanks!! I saw tons of related info from msdn.
I appreciate your help.
0
 
GhasanoCommented:
i'm glad i helped
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

  • 28
  • 12
  • 6
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now