Forums

ASP

This topic is locked

How do i run a vbscript in a webpage????

Posted 11 Nov 2002 10:52:17
1
has voted
11 Nov 2002 10:52:17 Henrik Sandeberg posted:
I have this code, it should show me the computername:

LISTING 2: VBScript to Read the Machine Name Environment Variable

Dim Shell
Dim CompName

Set Shell = WScript.CreateObject("WScript.Shell"
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%"

Msgbox "The computer name is " & CompName

But how do i use it on a webpage. I cant get it work.

Replies

Replied 22 Nov 2002 06:30:23
22 Nov 2002 06:30:23 Dave Blohm replied:
Like so...

<%
Dim Shell
Dim CompName

Set Shell = CreateObject("WScript.Shell"
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%"

Response.Write "The computer name is " & CompName

%>

Doc
Rangewalk Digital Studios
Replied 18 Apr 2006 19:39:32
18 Apr 2006 19:39:32 ... ang3l007 replied:
Hi, we really need a script to show the computer name for a project.

We have tried your script but we get strange errors.

We are not sure that we have put the correct HTML around your VB code. Can you please give us an example of the whole thing with HTML included? Also, do you know a way to display the PC's Workgroup / domain as well as its name?

Thanks & Regards

Angel
Replied 21 Apr 2006 07:20:01
21 Apr 2006 07:20:01 micah santos replied:

just wanna make it clear that these codes won't run if you used HTML. you must run it using a *.ASP file extension.

e.g.

SHOWPC.ASP
Replied 21 Apr 2006 07:29:12
21 Apr 2006 07:29:12 micah santos replied:
<%

Dim objShell
Dim pcInfo

On Error Resume Next

Set objShell = CreateObject("WScript.NetWork"

If Err.Number <> 0 Then
response.write "ERROR"
End if


pcInfo = "User Name is " & objShell.UserName & "<br>" &_
"PC Name is " & objShell.ComputerName & "<br>" & _
"Domain Name is " & objShell.UserDomain

response.write pcInfo

Set objShell = Nothing

%>
Replied 21 Apr 2006 16:34:49
21 Apr 2006 16:34:49 ... ang3l007 replied:
Hi, Thanks for the feedback but this asp shows the name and user at the SERVER level. We want a script that will run on the user's PC to show HIS PC name and not that of the server running the web site.

Any ideas?

Replied 21 Apr 2006 17:07:09
21 Apr 2006 17:07:09 micah santos replied:
then use the codes revised into ASP by Dave you posted here. it works fine.

<%
Dim Shell
Dim CompName

Set Shell = CreateObject("WScript.Shell"
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%"

Response.Write "The computer name is " & CompName

%>

Replied 21 Apr 2006 22:09:39
21 Apr 2006 22:09:39 ... ang3l007 replied:
Yes it works but it show only the computer name, user and domain of the WEB SERVER (but not of the user which browse on this page).

We need a script which show the PC & USER name "of the visitor" when he browse on the page...
Replied 22 Apr 2006 00:15:15
22 Apr 2006 00:15:15 micah santos replied:
Replied 27 Apr 2006 20:05:46
27 Apr 2006 20:05:46 Dave Blohm replied:
odd...I posted a response, but it's not in the thread...

What errors are you getting? Do you have access to the way that the authentication is being handled at the server level?


Doc
Wycked Studios
wyckedstudios.com
Replied 28 Apr 2006 14:37:19
28 Apr 2006 14:37:19 Patrick Woldberg replied:
Instead of placing <% %> around it use <script language="vbscript"> </script>, this will run the script clientside. This only works on Windows.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
Replied 28 Apr 2006 15:45:28
28 Apr 2006 15:45:28 ... ang3l007 replied:
I have put the page on a free website. You can view at:

membres.lycos.fr/localhost0/

The script, the source and a zip with the html and vbs code is available to download. If you find any errors or the solution to run this script on a website, please reply here...

Many thanks for your help.

Reply to this topic