-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.bat
173 lines (145 loc) · 4.95 KB
/
main.bat
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
:: Use only under MIT License
:: If you want to Publish a modified Version please mention the Original Creator PIRANY and link the GitHub Repo
:: Some Startup Stuff (yk)
cls
@echo off
@color 02
::Sets the Directory to the right one after Elevated
pushd "%~dp0"
::Screen Stuff
mode con: cols=76 lines=30
set "scriptstart=%time%"
@title Starting Up...
echo Starting Up...
@setlocal enableextensions ENABLEDELAYEDEXPANSION
:: Checks if the Script is started by a debug Script
:: update part to be linked here
@if defined debug_assist @ECHO ON
@if defined devtools goto devpart
:: Allows ASCII Art to be Used in the Script (50/50 pasted) Instead of Echo Use %$Echo% "
SETLOCAL EnableDelayedExpansion
SET $Echo=FOR %%I IN (1 2) DO IF %%I==2 (SETLOCAL EnableDelayedExpansion ^& FOR %%A IN (^^^!Text:""^^^^^=^^^^^"^^^!) DO ENDLOCAL ^& ENDLOCAL ^& ECHO %%~A) ELSE SETLOCAL DisableDelayedExpansion ^& SET Text=
SETLOCAL DisableDelayedExpansion
:: Presets some Variables when used in cal
set "elevated="
set "exitcode="
set "gitver12=v0"
set "-= "
::Checks if the OpenVPN GUI Executable exists.
if not exist "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" goto :installation-not-found
:: Checks if the Script is elevated
:checkelev
net session >nul 2>&1
if %errorLevel% == 0 ( set "elevated=1" ) else ( set "elevated=0")
:: Checks if the Config already exists and if not creates one
if exist "%USERPROFILE%\Documents\OpenVPN-CLI-Tools\config.txt" (goto config-exists) else (goto create-config)
:create-config
cd /d %USERPROFILE%\Documents\
mkdir OpenVPN-CLI-Tools
cd /d OpenVPN-CLI-Tools
echo :: This File was created by OpenVPN-CLI-Tools. It may be valuable if you used OpenVPN-CLI-Tools once. > config.txt
echo Added Config File to: "%USERPROFILE%\Documents\OpenVPN-CLI-Tools\"
echo Moving Script to: "%USERPROFILE%\Documents\OpenVPN-CLI-Tools\"
cd /d %~dp0
xcopy main.bat %USERPROFILE%\Documents\OpenVPN-CLI-Tools\ /q /y
cd /d %USERPROFILE%\Documents\OpenVPN-CLI-Tools\
goto config-exists
:: Extracts Data from Config, if avaiable
:config-exists
cd /d %USERPROFILE%\Documents\OpenVPN-CLI-Tools\
set /p config=<config.txt
echo %config%
@ping -n 2 localhost> nul
set "startuptimeend=%time%"
goto main
:: ------------
:: Startup Done
:: ------------
:: Main Part
:main
cls
@title OpenVPN-CLI-Tool
%$Echo% " __ __ ___ __ __ ___ __ __ __
%$Echo% " / \ |__) |__ |\ | \ / |__) |\ | __ / ` | | __ | / \ / \ | /__`
%$Echo% " \__/ | |___ | \| \/ | | \| \__, |___ | | \__/ \__/ |___ .__/
echo.
echo [1] Info
echo.
echo [2] Add to Path
echo.
echo [3] Autostart
echo.
echo [4] Settings
echo.
echo [5] Check for Updates
echo.
echo [6] Open the Github-Repo
echo.
echo [7] Delete Script
echo.
echo [8] Exit
echo.
echo Enter a menu option in the Keyboard [1,2,3,4,5,6,7] :
choice /C 12345678 /N
set _erl=%errorlevel%
if %_erl%==8 cls & echo OpenVPN-Tools exited with Code 0 & exit /b 0
if %_erl%==7 cls & goto delete-script
if %_erl%==6 explorer https://github.com/PIRANY1/openvpn-cli-tools & cls % goto main
if %_erl%==5 setlocal & call check-updates & cls & endlocal & goto :main
if %_erl%==4 cls & goto settings
if %_erl%==3 cls & goto autostart
if %_erl%==2 cls & goto add-to-path
if %_erl%==1 cls & goto info
goto :main
:info
echo If you found an Error please create an Issue on the GithubRepo.
echo Please find Information about the Licensing in LICENSE or in the Github Repo
pause
goto main
:add-to-path
:autostart
:settings
:installation-not-found
echo The Script couldnt found the OpenVPN installation.
echo Please add the Path to the OpenVPN-gui.exe manually
echo It can look something like C:\Program Files\OpenVPN\bin\openvpn-gui.exe
set /p openvpn-exe=Enter the Path:
or
:delete-script
echo Are you Sure you want to delete the Script?
choice /C yn /M "Press Y to continue or N to go back:"
set _erl1=%errorlevel%
if %_erl1% == y goto delete-script-confirmed
if %_erl1% == n goto main
goto delete-script
:delete-script-confirmed
set "autostart-delete=Not Defined"
set "path-link-delete=Not defined"
goto delete-script-select
:delete-script-select
cls
title Delete OpenVPN-CLI-Tools
echo Do you want to Delete any Installed Features too?
echo.
echo [1] Autstart (%path-link-delete%)
echo.
echo [2] Add to Path (%autostart-delete%)
echo.
echo [3] Continue
echo.
choice /C 123 /M Choose which Features to delete by Pressing 1 and/or 2 and 3 to Continue:
set _erl=%errorlevel%
if %_erl%==3 cls & goto delete-script-selected
if %_erl%==2 cls & goto path-include
if %_erl%==1 cls & goto autostart-include
:autostart-include
cls
set "autostart-select-status=Included"
set "autstart-delete=1"
goto delete-script-select
:path-include
cls
set "path-select-status=Included"
set "path-delete=1"
goto delete-script-select
exit /b 0