Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to get a sample MS vb script to work 1

Status
Not open for further replies.

marekjk

IS-IT--Management
Aug 23, 2006
5
0
0
US
I'm trying to get the following script to work:


This is supposed to clear the server DNS cache. I need to do it through a script so that I can schedule it to run every few hours. Clearly I am pretty new to MS scripting.

In order to run that script I also needed to install this:

url=/library/en-us/dns/dns/installing_the_provider.asp


Problem:

When I run it I get an error message. This is the message I get: " clearcache_test.vbs(2, 1) (null): 0x8004100E " --without quotes.

I tried looking it up and I found that it translates into something missing. Honestly I don't think I modified the script correctly.

Any help is appreciated.
 
Your error is most likely due to a wrapping problem. Here is the same script without the multi lines. Copy this text to NOTEPAD then save it with a vbs extension.

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Cache")

For Each objItem in colItems
    objItem.ClearCache()
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I found a utility called dnscmd.exe, which allows for command line functions... I used that. If it does not work out I'll try your way, since I already made the changes to the servers yesterday. Thanks for your help, I do appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top