VBScript runtime error in ASP

Discussion in 'ASP' started by ccc, Oct 11, 2007.

  1. ccc

    ccc New Member

    Joined:
    Oct 11, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi

    I put a VB script into asp to show an internal IP address and computer name in the browser:
    Code:
    <%@ LANGUAGE="VBSCRIPT" %>
    
       <HTML>
       <HEAD>
       <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
       <META **********="Content-Type" content="text/html;charset=iso-8859-1">
       <TITLE>Document Title</TITLE>
       </HEAD>
       <BODY>
    
    <%
    
    arAddresses = GetIPAddresses()
    
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    
    info = ""
    
    for each ip in arAddresses
        info = info & ip
    next
    
      WScript.echo  "You IP address = " & info & "   " & "   "  & "You Computer Name = " & WshNetwork.ComputerName
    
    
    Function GetFQDN(ipaddress)
    '====
    ' Returns Fully Qualified Domain Name
    ' from reverse DNS lookup via nslookup.exe
    ' only implemented for NT4, 2000
    '====
      set sh = createobject("wscript.shell")
      set fso = createobject("scripting.filesystemobject")
      Set Env = sh.Environment("PROCESS")
    
      if Env("OS") = "Windows_NT" then
        workfile = fso.gettempname
        sh.run "%comspec% /c nslookup " & ipaddress & "  > " & workfile,0,true
       set sh = nothing
       set ts = fso.opentextfile(workfile)
       data = split(ts.readall,vbcr)
       ts.close
       set ts = nothing
       fso.deletefile workfile
       set fso = nothing
      for n = 0 to ubound(data)
        if instr(data(n),"Name") then
          parts = split(data(n),":")
            hostname= trim(cstr(parts(1)))
           Exit For
        end if
        hostname = "could not resolve IP address"
      next
        GetFQDN = hostname
      else
       set sh = nothing
       set fso = nothing
       GetFQDN = ""
      end if
    End Function
    
    
    Function GetIPAddresses()
    '=====
    ' Returns array of IP Addresses as output
    ' by ipconfig or winipcfg...
    '
    ' Win98/WinNT have ipconfig (Win95 doesn't)
    ' Win98/Win95 have winipcfg (WinNt doesn't)
    '
    ' Note: The PPP Adapter (Dial Up Adapter) is
    ' excluded if not connected (IP address will be 0.0.0.0)
    ' and included if it is connected.
    '=====
      set sh = createobject("wscript.shell")
      set fso = createobject("scripting.filesystemobject")
    
      Set Env = sh.Environment("PROCESS")
      if Env("OS") = "Windows_NT" then
        workfile = fso.gettempname
        sh.run "%comspec% /c ipconfig > " & workfile,0,true
      else
        'winipcfg in batch mode sends output to
        'filename winipcfg.out
        workfile = "winipcfg.out"
        sh.run "winipcfg /batch" ,0,true
      end if
      set sh = nothing
      set ts = fso.opentextfile(workfile)
      data = split(ts.readall,vbcr)
      ts.close
      set ts = nothing
      fso.deletefile workfile
      set fso = nothing
      arIPAddress = array()
      index = -1
      for n = 0 to ubound(data)
        if instr(data(n),"IP Address") then
          parts = split(data(n),":")
          if trim(parts(1)) <> "0.0.0.0" then
            index = index + 1
            ReDim Preserve arIPAddress(index)
            arIPAddress(index)= trim(cstr(parts(1)))
          end if
        end if
      next
      GetIPAddresses = arIPAddress
    
    
    End Function
    
    %>
    
    </BODY>
    </HTML>
    and get this error message:
    Code:
    Technical Information (for support personnel)
    
        * Error Type:
          Microsoft VBScript runtime (0x800A0035)
          File not found
          /server/performance/default.asp, line 89
    this VB script without asp works well.

    knows someone howto solve this problem ?
     
  2. urstop

    urstop New Member

    Joined:
    Oct 17, 2007
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    0
    Do you see the temp file being created without any issues. The problem looks like the file is not getting created or something like that and when u try to open it after that the code fails.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice