Archive: Write nameserver


Write nameserver
I'm writing a little script for set to any network connection opendns as default nameserver for children protection.
For do this, for any connection I need to set the default dns with the key nameserver.
I'm working at school but I'm new with this sistem.
Can you help me ?
I've write this but it dont work :-(

Name "Prova"
OutFile "prova.exe"

!include "Registry.nsh"
!include "Sections.nsh"

Var RADIOBUTTON

Page components
Page instfiles


Section /o "Search for value 'Tcpip\Parameters\Interfaces'" SearchValue
${registry::Open} "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\" "/K=0 /V=1 /S=0 /B=1 /N='NameServer'" $0
StrCmp $0 0 0 loop
MessageBox MB_OK "Error" IDOK close

loop:
${registry::Find} "$0" $1 $2 $3 $4

MessageBox MB_OKCANCEL '$$1 "path" =[$1]$\n\
$$2 "value" =[$2]$\n\
$$3 "string" =[$3]$\n\
$$4 "type" =[$4]$\n\
$\n\
Find next?' IDOK loop
${registry::Write} "$1" "$2" "123.123.123.123,123.123.123.123" "$4" $vara
close:
${registry::Close} "$0"
${registry::Unload}
SectionEnd

Function .onInit
StrCpy $RADIOBUTTON ${SearchValue}
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $RADIOBUTTON
!insertmacro RadioButton ${SearchValue}
!insertmacro EndRadioButtons
FunctionEnd


I hope you can help me becouse I think is a 2 minute work for you :-)

Really thanks in any case.


OMG, THINK OF THE CHILDREN!!!

anyway, ControlSet001 is wrong, it should be CurrentControlSet, but thats not the real problem, I'm sure there is an actual API you can call to set it, the best I can think of at this point is to use netsh.exe (XP and later probably)