Answer the question
In order to leave comments, you need to log in
Is it possible to create one .bat file for connecting and disconnecting to the internet?
I found this .bat file to connect:
cd %systemroot%\system32
start rasdial [имя_подключения] [имя_пользователя] [пароль]
cd %systemroot%\system32
start rasdial [имя_подключения] /disconnect
Answer the question
In order to leave comments, you need to log in
Given the idea of GavriKos :
ping -n 2 8.8.8.8|Find /I "TTL="||goto no_inet
cd %systemroot%\system32
start rasdial [имя_подключения] /disconnect
goto end
:no_inet
cd %systemroot%\system32
start rasdial [имя_подключения] [имя_пользователя] [пароль]
:end
Python is in your hands. Ping 8.8.8.8, and depending on the availability, choose what to do. You can directly rasdial from Python and call it, if that.
powershell script, but will run from a bat file if you have Windows 8 and higher
If the OS is lower than Windows 8, then here is the contents of the batch file:
ping хост -n 1 > %TEMP%\ping1.txt
if %errorlevel%==1 (rasdial название_ВПН_соединения логин пароль) else (rasdial название_ВПН_соединения /disconnect)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question