forked from Flowseal/zapret-discord-youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_install.bat
121 lines (100 loc) · 3.11 KB
/
service_install.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
@echo off
setlocal EnableDelayedExpansion
chcp 65001 >nul
:: 65001 - UTF-8
set "arg=%1"
if "%arg%" == "admin" (
echo Restarted with admin rights
) else (
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"\"%~f0\" admin\"' -Verb RunAs"
exit /b
)
cd /d "%~dp0"
call check_updates.bat soft
echo:
set BIN_PATH=%~dp0bin\
:: Searching for .bat files in current folder, except files that start with "service"
set "count=0"
for %%f in (*.bat) do (
set "filename=%%~nxf"
if /i not "!filename:~0,7!"=="service" if /i not "!filename:~0,13!"=="check_updates" (
set /a count+=1
echo !count!. %%f
set "file!count!=%%f"
)
)
:: Choosing file
set "choice="
set /p "choice=Input file index (number): "
if "!choice!"=="" goto :eof
set "selectedFile=!file%choice%!"
if not defined selectedFile (
echo Wrong choice, exiting..
pause
goto :eof
)
:: Parsing args (mergeargs: 2=start wf|1=wf argument|0=default)
set "args="
set "capture=0"
set "mergeargs=0"
set QUOTE="
for /f "tokens=*" %%a in ('type "!selectedFile!"') do (
set "line=%%a"
echo !line! | findstr /i "%BIN%winws.exe" >nul
if not errorlevel 1 (
set "capture=1"
)
if !capture!==1 (
if not defined args (
set "line=!line:*%BIN%winws.exe"=!"
)
set "temp_args="
for %%i in (!line!) do (
set "arg=%%i"
if not "!arg!"=="^" (
if "!arg:~0,2!" EQU "--" if not !mergeargs!==0 (
set "mergeargs=0"
)
if "!arg:~0,1!" EQU "!QUOTE!" (
set "arg=!arg:~1,-1!"
echo !arg! | findstr ":" >nul
if !errorlevel!==0 (
set "arg=\!QUOTE!!arg!\!QUOTE!"
) else if "!arg:~0,1!"=="@" (
set "arg=\!QUOTE!@%~dp0!arg:~1!\!QUOTE!"
) else if "!arg:~0,5!"=="%%BIN%%" (
set "arg=\!QUOTE!!BIN_PATH!!arg:~5!\!QUOTE!"
) else (
set "arg=\!QUOTE!%~dp0!arg!\!QUOTE!"
)
)
if !mergeargs!==1 (
set "temp_args=!temp_args!,!arg!"
) else (
set "temp_args=!temp_args! !arg!"
)
if "!arg:~0,4!" EQU "--wf" (
set "mergeargs=2"
) else if "!arg!" EQU "--dpi-desync" (
set "mergeargs=2"
) else if "!arg!" EQU "--dpi-desync-fooling" (
set "mergeargs=2"
) else if !mergeargs!==2 (
set "mergeargs=1"
)
)
)
if not "!temp_args!"=="" (
set "args=!args! !temp_args!"
)
)
)
:: Creating service with parsed args
set ARGS=%args%
echo Final args: !ARGS!
set SRVCNAME=zapret
net stop %SRVCNAME%
sc delete %SRVCNAME%
sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto
sc description %SRVCNAME% "zapret DPI bypass software"
sc start %SRVCNAME%