Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6759751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:59:14+00:00 2026-05-26T13:59:14+00:00

<script language=VBScript> Option Explicit ‘ On Error Resume Next Dim colIPResults, objFile, objFSO, objNIC,

  • 0
<script language="VBScript">
Option Explicit
' On Error Resume Next


Dim colIPResults, objFile, objFSO, objNIC, objWMI, objWSHNetwork, strAddresses, strIPAddress, strWQL
Const FOR_APPENDING = 8

Sub DestroyObjects()
If IsObject(objFile) Then Set objFile = Nothing
If IsObject(objFSO) Then Set objFSO = Nothing
If IsObject(objWMI) Then Set objWMI = Nothing
If IsObject(objWSHNetwork) Then Set objWSHNetwork = Nothing
' If IsObject() Then Set = Nothing
End Sub


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWSHNetwork = CreateObject("WScript.Network")
Set objWMI = GetObject("WinMGMTS:root\cimv2")
Set StrComputer = objWSHNetwork.Computername 
strWQL = "SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'"
Set colIPResults = objWMI.ExecQuery(strWQL)
For Each objNIC In colIPResults
For Each strIPAddress in objNIC.IPAddress
If strAddresses = "" Then
strAddresses = strIPAddress
Else
strAddresses = strAddresses
End If
Next
Next

Document.write("PC Tag Number: " + StrComputer)

If strAddresses ="0.0.0.0" Or strAddresses ="" or strAddresses = "undefined" Then
    Document.write("No Connection Detected")
Else
    Document.write "Network Address - "+ strAddresses
End If

DestroyObjects()
</script>

It keeps telling me that the variable is undefined!

(variable for StrComputer)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:59:14+00:00Added an answer on May 26, 2026 at 1:59 pm

    You never declared StrComputer on line 6.

    To elaborate a bit here, you used the Option Explicit which means that you must declare all of your variables before you use them even though we’re in VBScript. Because of this you must include StrComputer in your Dim statement on line 6.

    Dim colIPResults, objFile, objFSO, objNIC, objWMI, objWSHNetwork, strAddresses, strIPAddress, strWQL, StrComputer.

    Also, you appear to have changed the naming convention to use an upper case first letter rather than a lower case (StrComputer vs. strComputer). Although you can certainly name it however you want, you may want to stay consistent so you don’t end up with buggy code that still looks right when you read through it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating script for automated testing of financial application. Using VbScript as language. Need
I'm registering a javascript in aspx.net Dim script = <script language = javascript> &
I'm using script language ChaiScript with c++ and Qt. I've defined such function: void
I have written a simple brainfuck interpreter in MATLAB script language. It is fed
Does anybody have a PHP (or other language) script for drawing a spiral. A
What language and libraries are suitable for a script to parse and download small
I have some script in my default page that redirects users to language specific
Has anybody tried to use JavaFX Script in server side applications? The language itself
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
I have this script on my html page: <script language='javascript'>parent.resizeTo(550,510);</script> I'd like to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.