Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change DNS Setting programically
#4
This is vbscript below works

Code:
Copy      Help
On Error Resume Next

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

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array("156.154.70.22", "156.154.71.22")
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next

But if I was to convert it to QM, any ideas how its done.

Currently I do this below but didnt work. :?:

Code:
Copy      Help
lpstr code=
  On Error Resume Next

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

  Set colNetCards = objWMIService.ExecQuery _
      ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

  For Each objNetCard in colNetCards
      arrDNSServers = Array("156.154.70.22", "156.154.71.22")
      objNetCard.SetDNSServerSearchOrder(arrDNSServers)
  Next
VbsExec code

But this simple msgbox below works. :?:

Code:
Copy      Help
lpstr code=
  MsgBox "hi its me."
VbsExec code


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)