Posts: 82
Threads: 31
Joined: Oct 2007
When I am fixing one of my customers computers, one thing I always do is change their DNS settings to a better (more secure) DNS server. Usually Comodo, Google or Symantec DNS because they offer protection from bad sites. Is there a way to change these settings without having delve into the control panel and change them? I want to try and speed up (and automate) many of my routine tasks while fixing a computer and it would be great if I could automate the DNS settings change.
For example, change the current DNS to "156.154.70.22 and 156.154.71.22" (Comodo)
Thanks,
Jason
Posts: 12,097
Threads: 142
Joined: Dec 2002
QM does not have a function for this, but it is possible, I found something in google.
Posts: 82
Threads: 31
Joined: Oct 2007
I will search Google, thank you Gin.
Posts: 25
Threads: 4
Joined: Oct 2010
This is vbscript below works
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. :?:
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. :?:
lpstr code=
MsgBox "hi its me."
VbsExec code
Posts: 12,097
Threads: 142
Joined: Dec 2002
Maybe some lines in the VBScript code are empty. Then the multiline string ends. Must be space.
Macro
Macro650
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
Posts: 25
Threads: 4
Joined: Oct 2010
Thanks alot, it work perfectly now, maybe you right, I left some spaces in between.
One more question, how do I go about converting this vbscript below correctly to QM vbscript format?
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
' open maximized and wait
WSHShell.Run "notepad.exe", 3, true
' open minimized and wait
WSHShell.Run "notepad.exe", 2, true
' open normal and don't wait
WSHShell.Run "notepad.exe", 1, false
Set WSHShell = Nothing
WScript.Quit(0)
I know its mention wscript cant be use in QM, for Wscript.Echo, I can replace with MsgBox but what about Wscript.Shell like the above code? :?:
Posts: 12,097
Threads: 142
Joined: Dec 2002
Delete WScript. and will work.
Set WSHShell = CreateObject("WScript.Shell")
Posts: 25
Threads: 4
Joined: Oct 2010
Thanks it work, heres the working code. BTW Wscript.Quit(0) have to be remove too.
Macro
VbscriptNotepad
lpstr code=
;Dim WSHShell
;Set WSHShell = CreateObject("WScript.Shell")
;
;;
;WSHShell.Run "notepad.exe", 3, true
;
;WSHShell.Run "notepad.exe", 2, true
;
;WSHShell.Run "notepad.exe", 1, false
;
;Set WSHShell = Nothing
VbsExec code