Skip navigation

Rem: Using Nslookup with Random IP Addresses


I need to use the Windows Nslookup command with constantly changing IP addresses to look up DNS information. As Listing 3 shows, I'm trying to launch the command with the Exec method of Windows Script Host's (WSH's) WshShell object. However, the third line in this code returns an Object Required error. Do you know why this error is occurring?

The problem is the incorrect use of the VBScript Set statement in the second line. The Set statement is used to initialize object references, not strings, integers, dates, arrays, and the like. (To learn more about the Set statement, go to So, simply remove Set from the beginning of the second line, and you should be set (no pun intended).

Listing 4 shows the corrected code, which is a script called WshScriptExec.vbs. I enhanced your code by adding support for passing in the target IP address from the command line. To launch WshScriptExec.vbs, type

cscript //nologo
  WshScriptExec.vbs \[IpAddress\]

where IpAddress is the IP address you want to look up. If you don't enter an IP address on the command line, the script enters the default IP address specified in the code that callout A in Listing 4 shows.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.