slyfox1186

expressvpn-connection-master.bat

Sep 29th, 2021 (edited)
1,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.48 KB | None | 0 0
  1. @ECHO OFF
  2. SETLOCAL ENABLEEXTENSIONS
  3. COLOR 0A
  4. TITLE ExpressVPN Client Command Line Script
  5.  
  6. :----------------------------------------------------------------------------------
  7.  
  8. REM Created by: SlyFox1186
  9. REM Web: https://pastebin.com/u/slyfox1186
  10.  
  11. REM Command line to connect to an ExpressVPN server by
  12. REM using the 3rd party app "expresso.exe".
  13. REM Download: https://github.com/sttz/expresso
  14.  
  15. REM Place this script in the same directory as "expresso.exe".
  16.  
  17. REM This script will start or restart the ExpressVPN
  18. REM service before connecting to the VPN server to
  19. REM ensure the client runs correctly.
  20.  
  21. REM For a list of commands run: expresso.exe -h
  22.  
  23. REM Make sure to change the variable SERVER to your preference.
  24.  
  25. :----------------------------------------------------------------------------------
  26.  
  27. PUSHD "%~dp0"
  28. REM Uncomment the next line to start the cmd.exe window minimized.
  29. :: IF NOT "%1"=="MIN" START /MIN CMD /D /C %0 MIN & GOTO :EOF
  30.  
  31. :----------------------------------------------------------------------------------
  32. :RESTART
  33. :----------------------------------------------------------------------------------
  34.  
  35. REM Edit the SERVER number variable below to your desired server.
  36. REM To get the list of servers run: expresso.exe alfred --locations
  37. SET SERVER=19
  38.  
  39. :----------------------------------------------------------------------------------
  40.  
  41. ECHO What would you like to do? & ECHO=
  42. ECHO [1] Connect/Disconnect
  43. ECHO [2] List Servers
  44. ECHO [3] Exit & ECHO=
  45.  
  46. CHOICE /C 123 /N & CLS
  47.  
  48. IF ERRORLEVEL 3 GOTO :EOF
  49. IF ERRORLEVEL 2 GOTO LIST
  50. IF ERRORLEVEL 1 GOTO AUTO_CONNECT
  51.  
  52. :----------------------------------------------------------------------------------
  53. :LIST
  54. :----------------------------------------------------------------------------------
  55.  
  56. REM LIST ALL VPN SERVERS
  57. expresso.exe alfred --locations
  58. ECHO=
  59. PAUSE
  60. CLS & ENDLOCAL & GOTO RESTART
  61.  
  62. :----------------------------------------------------------------------------------
  63. :AUTO_CONNECT
  64. :----------------------------------------------------------------------------------
  65.  
  66. REM USE FINDSTR TO VERIFY IF EXPRESSPN IS CURRENTLY CONNECTED
  67. FOR /F "TOKENS=*" %%G IN ('expresso.exe disconnect ^| FINDSTR "VPN is not connected"') DO (
  68.     IF /I NOT "%%G" NEQ "VPN is not connected" (
  69.         ECHO Connecting ExpressVPN, please wait..
  70.         net stop "ExpressVPNService" >NUL
  71.         net start "ExpressVPNService" >NUL
  72.         CLS
  73.         expresso.exe connect --change %SERVER%
  74.       ) ELSE (
  75.         expresso.exe disconnect
  76.     )
  77. )
  78.  
  79. TIMEOUT 3 >NUL
Add Comment
Please, Sign In to add comment