MS-DOS: Configure Network Example

Use the following code as an example in a .bat file:

@ECHO OFF
echo Network Environments:
echo ---------------------
echo 1.Home
echo 2.WORK
echo 3.EKP
echo 4.exit
echo ---------------------
:GETINPUT
set /p network_option=Please enter a number:

if "%network_option%"=="1" (GOTO HOME)
if "%network_option%"=="2" (GOTO WORK)
if "%network_option%"=="3" (GOTO EKP)
if "%network_option%"=="4" (GOTO EXIT)

:HOME
rem DHCP:
netsh interface ip set address name="Local Area Connection" source=dhcp
rem NO proxy:
set reg=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Reg Add "%reg%" /v "ProxyEnable" /t "REG_DWORD" /d "0" /f
GOTO EXIT

:WORK
rem DHCP:
netsh interface ip set address name="Local Area Connection" source=dhcp
rem USE proxy:
set reg=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Reg Add "%reg%" /v "ProxyEnable" /t "REG_DWORD" /d "1" /f
Reg Add "%reg%" /v "ProxyServer" /t "REG_SZ" /d "proxy.work.us:8080" /f
GOTO EXIT

:EKP
rem STATIC:
netsh interface ip set address local static 195.134.119.23 255.255.255.128 195.134.119.1 1
netsh interface ip set dns name="Local Area Connection" static 195.134.100.90
netsh interface ip add dns name="Local Area Connection" 195.137.100.100
rem NO proxy:
set reg=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Reg Add "%reg%" /v "ProxyEnable" /t "REG_DWORD" /d "0" /f
GOTO EXIT

rem test:
rem start iexplore http://www.google.com


:EXIT
exit

Leave a Reply