Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


June 14, 2004

Rem: Using Nslookup with Random IP Addresses


RSS
View this exclusive article with VIP access -- click here to join |
See More Domain Name System (DNS) Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsstmset.asp.) 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. . . .

Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...


Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing