7

Classic aspects of the ASP VBScript return PC name

 2 years ago
source link: https://www.codesd.com/item/classic-aspects-of-the-asp-vbscript-return-pc-name.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Classic aspects of the ASP VBScript return PC name

advertisements

EDIT - Better asked maybe I need to get the value from the VBScript variable NAME into the ASP form, any attempt to reference the variable other than print it to the screen is ignored.

this is on an intranet, only for internal use, and IE is used at the lowest security settings so the activeX runs without prompting.

I have a vbscript that when it runs returns what I am looking for - the client PC name

<script language="vbscript">
<!--

    Set objNetwork = CreateObject("WScript.Network") 

    NAME= objNetwork.computername

    document.write(NAME)

//--> 

</script>

When I run the following I get the server name:

<%
    Set objNetwork = CreateObject("WScript.Network") 

    strNAME = objNetwork.computername

    response.write("Value of strNAME variable: " & strNAME & "<br>")
%>

I need the actual PC name that the VBScript returns, and I need to insert that into a form. Using the ASP I can do the fill of the form but it gives me the server name and I need the VBScript PC Client name. I can not figure out how to get the VBScript name into the ASP form.


You need client side VBScript:

<script language="vbscript">
<!--

Function SetComputerName
    Set objNetwork = CreateObject("WScript.Network")
    NAME=objNetwork.computername
    Document.Forms("form1").Elements("computername").Value = NAME
End Function

SetComputerName()

//--> 

</script>

Put the form name or ID instead of "form1" and the input element name that should contain the computer name instead of "computername".

The script will work only if placed in the end of your HTML markup, or at least after the form HTML, if you want it placed above add such thing to your body tag: <body onload="SetComputerName()">


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK