Computer name in ASP

Hi,

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

Thanks in advance,
Shahid
Shahid Juma [ Di, 07 Dezember 2004 20:20 ] [ ID #524573 ]

Re: Computer name in ASP

"Shahid Juma" wrote ...

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

Of the client computer I don't think you'll be able to being that the ASP
will be run server side...

Not sure if you can extract this with Javascript - I'd be surprised though
for security reasons etc...

Something here:

http://www.experts-exchange.com/Web/Q_20595825.html

Regards

Rob
Rob Meade [ Di, 07 Dezember 2004 20:27 ] [ ID #524575 ]

Re: Computer name in ASP

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 [at] 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





"Shahid Juma" <shahid319REMOVETHIS [at] hotmail.com> wrote in message
news:uw0f5DJ3EHA.936 [at] TK2MSFTNGP12.phx.gbl...
> Hi,
>
> How can I retrieve the computer name of the browser and output it to the
> webpage in ASP/VBScript?
>
> Thanks in advance,
> Shahid
>
>
my first name at lane [ Di, 07 Dezember 2004 20:35 ] [ ID #524576 ]

Re: Computer name in ASP

Shahid Juma wrote:
> 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
Mike Brind [ Di, 07 Dezember 2004 20:39 ] [ ID #524577 ]

Re: Computer name in ASP

Thanks,

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

Thanks,
Shahid

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%23OC8mPJ3EHA.1264 [at] TK2MSFTNGP12.phx.gbl...
> 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 [at] 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
>
>
>
>
>
> "Shahid Juma" <shahid319REMOVETHIS [at] hotmail.com> wrote in message
> news:uw0f5DJ3EHA.936 [at] TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > How can I retrieve the computer name of the browser and output it to the
> > webpage in ASP/VBScript?
> >
> > Thanks in advance,
> > Shahid
> >
> >
>
>
Shahid Juma [ Di, 07 Dezember 2004 21:03 ] [ ID #524580 ]

Re: Computer name in ASP

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

"Shahid Juma" <shahid319REMOVETHIS [at] hotmail.com> wrote in message
news:ebbgvbJ3EHA.2804 [at] TK2MSFTNGP15.phx.gbl...
> Thanks,
>
> I tried it and I get an "Access Denied", are there any permissions I need
to
> set?
>
> Thanks,
> Shahid
>
> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> message news:%23OC8mPJ3EHA.1264 [at] TK2MSFTNGP12.phx.gbl...
> > 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 [at] echo off & for /f ""tokens=2"" %q in ('ping -
my first name at lane [ Di, 07 Dezember 2004 21:02 ] [ ID #524582 ]

Re: Computer name in ASP

Mike Brind wrote:
> Shahid Juma wrote:
>
>> 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

Answered in other replies.
Mike Brind [ Di, 07 Dezember 2004 22:16 ] [ ID #524585 ]

Re: Computer name in ASP

On Tue, 7 Dec 2004 14:20:50 -0500, "Shahid Juma"
<shahid319REMOVETHIS [at] hotmail.com> wrote:

>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
jeff.nospam [ Di, 07 Dezember 2004 22:18 ] [ ID #524588 ]
Webserver » microsoft.public.inetserver.asp.general » Computer name in ASP

Vorheriges Thema: Re: Submit button on form
Nächstes Thema: Passing value from page to page