Computer name in ASP

S

Shahid Juma

Hi,

How can I retrieve the computer name of the browser and output it to the
webpage in ASP/VBScript?

Thanks in advance,
Shahid
 
R

Ray Costanzo [MVP]

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

Ray at work
 
M

Mike Brind

Shahid said:
Hi,

How can I retrieve the computer name of the browser and output it to the
webpage in ASP/VBScript?

Thanks in advance,
Shahid

What do you mean by "computer name"?

Mike Brind
 
R

Ray Costanzo [MVP]

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.

Ray at work
 
S

Shahid Juma

Thanks,

I tried it and I get an "Access Denied", are there any permissions I need to
set?

Thanks,
Shahid
 
J

Jeff Cochran

Hi,

How can I retrieve the computer name of the browser and output it to the
webpage in ASP/VBScript?

Does Request.ServerVariables("REMOTE_HOST") get you what you need?

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top