Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Released under the GNU General Public License version 3 by J2897.
- :: This script will set a static IP address.
- @echo OFF
- setlocal
- ver | find "Version 6." > nul
- if %ERRORLEVEL% == 0 (
- REM Do OPENFILES to check for administrative privileges
- openfiles >nul
- if errorlevel 1 (
- color cf
- echo.Right-click on this file and select 'Run as administrator'.
- endlocal
- pause
- color
- exit /b 1
- )
- )
- REM Custom variables.
- set "NET_NAME=Local Area Connection"
- set "IP=192.168.0.3"
- set "SUBNET_MASK=255.255.255.0"
- set "GATEWAY=192.168.0.1"
- set "DNS1=%GATEWAY%"
- set "DNS2=8.8.8.8"
- echo Setting static IP . . .
- netsh interface ip set address name="%NET_NAME%" static %IP% %SUBNET_MASK% %GATEWAY%
- echo Setting primary DNS server . . .
- netsh interface ip set dns name="%NET_NAME%" static %DNS1%
- echo Setting secondary DNS server . . .
- netsh interface ip add dns name="%NET_NAME%" %DNS2% index=2
- REM Revert to DHCP.
- :: netsh interface ip set address name="%NET_NAME%" source=dhcp
- :End
- endlocal
- echo.
- echo Ending . . .
- pause
- timeout /t 10 /nobreak >nul
- exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement