-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChange_Gateway.bat
More file actions
51 lines (48 loc) · 1.71 KB
/
Copy pathChange_Gateway.bat
File metadata and controls
51 lines (48 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
rem All of the methodes can set up the basic settings visa netsh eg.
rem netsh interface ip set address "Local Area Connection" static 192.168.1.5 255.255.255.0 192.168.1.1 1
rem But non show how to set up the alternate tab. Even when people say export it via
rem netsh -c interface dump > c:\work-net.txt
rem then to import with
rem netsh -f c:\work-net.txt
rem It does not save the alternate network config, that is It will turn it off and on if you didnt change it but if you do then it will only show the last setting that was saved it doesnt update teh fields with the work-net.txt file.
rem Anyway mabe there is a registry setting somewhere.
::@echo off
setlocal
REM *** Host to test (Google)
set PingHost=74.125.226.166
REM *** Number of pings to send with each test:
set PingCount=10
REM *** Size of the ping packets in byte:
set PingSize=8
REM *** Time in seconds to wait between checks: 5 minutes = 300s
set Pause=300
:PingLoop
ping -4 -l %PingSize% -n %PingCount% %PingHost% | find "TTL" >NUL
if not errorlevel 1 (
ping.exe localhost -n %Pause% >NUL
::goto PingLoop
)
color 4F
echo Connection lost, trying to re-establish ...
REM ...
set "ip="
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "Default"') do if not defined ip set ip=%%b
::echo %ip
::echo %ip%
::echo "%ip"
::echo "%ip%"
::echo "%ip%" equ " 202.1.1.2"
if "%ip%" EQU " 202.1.1.2" (
REM set gateway here
echo "in first logic block"
netsh interface ip set address "Local Area Connection" static 202.1.1.223 255.255.255.0 202.1.1.4 1
) else (
REM set other gateway here
echo "in second logic block"
netsh interface ip set address "Local Area Connection" static 202.1.1.223 255.255.255.0 202.1.1.2 1
)
REM ...
color
echo Continuing check ...
::pause
::goto PingLoop