如何使用VB.NET删除DNS记录?

时间:2014-02-26 12:51:02

标签: vb.net dns wmi

我正在寻找一种方法来删除 DNS 记录,只指定记录的名称。 也许首先 nslookup 这个名称,搜索 FQDN 以了解区域,请求确认然后将其删除。

每个网页建议使用 DNSCMD ,但这是外部资源,我想在 VB.NET 代码中执行此操作,可能使用一些引用/库。< / p>

有没有办法在内部执行 WMI 调用?

1 个答案:

答案 0 :(得分:0)

' Connect to the WMI Service
Set objWMIService = GetObject("winmgmts:\dc01rootMicrosoftDNS")
' Run a query to get the record we want to change
Set colItems = objWMIService.ExecQuery("SELECT * FROM MicrosoftDNS_AType" & _
  " WHERE ContainerName='thezone.net' AND OwnerName='test.thezone.net'",,48)

' Loop through the results
For Each objItem in colItems
  ' Modify the record
  objItem.Modify objItem.TTL, "1.2.3.4"
Next

read this

相关问题