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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting DNS with VBScript 1

Status
Not open for further replies.

alepore

MIS
Jun 25, 2001
27
US
I am new to scripting and I was wondering if this is possible. I want to use the netsh command but I obviously have a problem putting quotes inside quotes. Is there another way to enter "Wireless Network Connection" in the objFso.run line? Any help will be appreciated.



Option Explicit
Dim objFso
Dim cNetwork
Dim cDNS
Dim Perm

Set objFso = CreateObject("WScript.Shell")
cDNS = MsgBox("Would you like to change to local DNS?", vbYesno)
If cDNS = vbYes Then
Perm = objFso.run("netsh interface ip set dns "Wireless Network Connection" static 1.1.1.1 primary",1,True)
Else
Perm = objFso.run("netsh interface ip set dns "Wireless Network Connection" static 2.2.2.2 primary",1,True)
End If


Set objFso=Nothing
 
Hello alepore,

Standard device applies.
Code:
cmdline="netsh interface ip set dns ""Wireless Network Connection"" static 1.1.1.1 primary"
Perm=objFso.run(cmdline,1,true)
or equivalently
Code:
cmdline="netsh interface ip set dns " & chr(34) & "Wireless Network Connection" & chr(34) & " static 1.1.1.1 primary"
Perm=objFso.run(cmdline,1,true)
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top