Automation Error VB6

A

Aek

I am getting
Error: Automation Error
Invalid Syntax

Any thoughts??

I get the message on running this code in WinPE environment.
Works fine from my loggged on machine.

I am calling:
setDNSSearchOrder(".")

That goes to the below function:

Function setDNSSearchOrder(host)
Dim aDNS(3)As String
Dim strComputer As String
Dim objWMIService As Object
Dim errDNS
Dim objItem As Object
Dim colItems As Object

'For all the enthusiasts who will just copy and run this script
msgbox "Please write down your DNS Search order: "

'DNS server search order
aDNS(0) = "1.1.1.1"
aDNS(1) = "1.1.1.2"
aDNS(2) = "1.1.1.3"
adns(3) = "1.1.1.4"

'Set Networking Managing Objects
strComputer = "."

' -> Program Bombs at the line below
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'I changed this to:
'Set objWMIService = GetObject("winmgmts:" _
'& "{impersonationLevel=impersonate}!\\" _
'& strComputer & "\root\cimv2")

'but dint help either.


Set colItems = objWMIService.ExecQuery("Select * From
Win32_NetworkAdapterConfiguration Where IPEnabled = 1")

' -> Changed the above line to Where IPEnabled = True , but dint work either.

For Each objItem In colItems
errDNS = objItem.SetDNSServerSearchOrder()
'WScript.Sleep 120000
errDNS = objItem.SetDNSServerSearchOrder(aDNS)
Next

Set objWMIService = Nothing
Set colItems = Nothing

msgbox "Just changed your DNS Search order: "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top