mirror of
https://github.com/Flowseal/zapret-discord-youtube.git
synced 2025-04-16 02:01:28 -07:00
Updates checker and cmd not terminating after service finish
This commit is contained in:
parent
5befdc2ac5
commit
fce0da4d0e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
version.txt
|
88
check_updates.bat
Normal file
88
check_updates.bat
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
chcp 437 > nul
|
||||||
|
|
||||||
|
set "CURRENT_VERSION=1.6.0"
|
||||||
|
set "GITHUB_URL=https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/refs/heads/main/.service/version.txt"
|
||||||
|
set "RELEASE_URL=https://github.com/Flowseal/zapret-discord-youtube/releases"
|
||||||
|
set "VERSION_FILE=version.txt"
|
||||||
|
set "SKIP_VERSION=null"
|
||||||
|
set "FILE_EXISTS=1"
|
||||||
|
|
||||||
|
for /f "delims=" %%A in ('powershell -command "[datetime]::Now.ToString('yyyy-MM-dd HH:mm:ss')"') do set CURRENT_TIMESTAMP=%%A
|
||||||
|
|
||||||
|
:: If file version.txt exists
|
||||||
|
if not exist %VERSION_FILE% (
|
||||||
|
set "FILE_EXISTS=0"
|
||||||
|
echo time: %CURRENT_TIMESTAMP%> %VERSION_FILE%
|
||||||
|
echo ver: %CURRENT_VERSION%>> %VERSION_FILE%
|
||||||
|
)
|
||||||
|
|
||||||
|
:: Reading data from local version.txt
|
||||||
|
for /f "tokens=1,* delims=: " %%A in (%VERSION_FILE%) do (
|
||||||
|
if "%%A"=="time" set "LAST_CHECK=%%B"
|
||||||
|
if "%%A"=="ver" set "INSTALLED_VERSION=%%B"
|
||||||
|
if "%%A"=="skip" set "SKIP_VERSION=%%B"
|
||||||
|
)
|
||||||
|
|
||||||
|
:: If file was called from thirdparty script (with 'soft' argument that blocks checking for 12 hours)
|
||||||
|
if "%~1"=="soft" (
|
||||||
|
:: Converting dates to parts for calculation
|
||||||
|
for /f "tokens=1-6 delims=-: " %%A in ("%CURRENT_TIMESTAMP%") do (
|
||||||
|
set "CURRENT_MONTH=%%B"
|
||||||
|
set "CURRENT_DAY=%%C"
|
||||||
|
set "CURRENT_HOUR=%%D"
|
||||||
|
)
|
||||||
|
for /f "tokens=1-6 delims=-: " %%A in ("%LAST_CHECK%") do (
|
||||||
|
set "LAST_MONTH=%%B"
|
||||||
|
set "LAST_DAY=%%C"
|
||||||
|
set "LAST_HOUR=%%D"
|
||||||
|
)
|
||||||
|
|
||||||
|
set /a "time_diff_in_minutes = (CURRENT_MONTH - LAST_MONTH) * 43200 + (CURRENT_DAY - LAST_DAY) * 1440 + (CURRENT_HOUR - LAST_HOUR) * 60"
|
||||||
|
|
||||||
|
if !time_diff_in_minutes! LEQ 360 if !FILE_EXISTS!==1 (
|
||||||
|
echo Skipping the update check because it hasnt been 6 hours
|
||||||
|
goto :EOF
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
:: Reading new version from github
|
||||||
|
set "NEW_VERSION="
|
||||||
|
for /f "delims=" %%A in ('powershell -command "(Invoke-WebRequest -Uri %GITHUB_URL% -TimeoutSec 5).Content" 2^>nul') do set "NEW_VERSION=%%A"
|
||||||
|
if not defined NEW_VERSION (
|
||||||
|
echo Erorr reading new version
|
||||||
|
goto :EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
:: Rewrite file
|
||||||
|
echo time: %CURRENT_TIMESTAMP%> %VERSION_FILE%
|
||||||
|
echo ver: %INSTALLED_VERSION%>> %VERSION_FILE%
|
||||||
|
echo skip: %SKIP_VERSION%>> %VERSION_FILE%
|
||||||
|
|
||||||
|
:: Comparing versions
|
||||||
|
if "%NEW_VERSION%"=="%INSTALLED_VERSION%" (
|
||||||
|
echo You are using the latest version %NEW_VERSION%.
|
||||||
|
goto :EOF
|
||||||
|
) else (
|
||||||
|
:: Check if version skipped
|
||||||
|
if "%NEW_VERSION%"=="%SKIP_VERSION%" (
|
||||||
|
echo Newer version %NEW_VERSION% skipped by user.
|
||||||
|
goto :EOF
|
||||||
|
) else (
|
||||||
|
echo New version found: %NEW_VERSION%.
|
||||||
|
echo Visit %RELEASE_URL% to download a new version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
:: Skip check
|
||||||
|
set /p "CHOICE=Skip this update? (y/n, default: n): " || set "CHOICE=n"
|
||||||
|
set "CHOICE=!CHOICE:~0,1!"
|
||||||
|
if /i "!CHOICE!"=="y" (
|
||||||
|
echo skip: %NEW_VERSION%>> %VERSION_FILE%
|
||||||
|
echo Update %NEW_VERSION% skipped.
|
||||||
|
) else (
|
||||||
|
start %RELEASE_URL%
|
||||||
|
)
|
||||||
|
|
||||||
|
endlocal
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ chcp 65001 >nul
|
|||||||
:: NOT RECOMMENDED
|
:: NOT RECOMMENDED
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ chcp 65001 >nul
|
|||||||
:: 65001 - UTF-8
|
:: 65001 - UTF-8
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
|
|
||||||
|
@ -4,16 +4,14 @@ chcp 65001 >nul
|
|||||||
|
|
||||||
set "arg=%1"
|
set "arg=%1"
|
||||||
if "%arg%" == "admin" (
|
if "%arg%" == "admin" (
|
||||||
echo Скрипт запущен с правами администратора
|
echo Restarted with admin rights
|
||||||
) else (
|
) else (
|
||||||
powershell -Command "Start-Process -FilePath '%~f0' -ArgumentList 'admin' -Verb RunAs"
|
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"%~f0 admin\"' -Verb RunAs"
|
||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Admin rights check
|
call check_updates.bat soft
|
||||||
echo Данный файл должен быть запущен с правами администратора (ПКМ - Запустить от имени администратора).
|
echo:
|
||||||
echo Нажмите любую клавишу, чтобы продолжить создание сервиса.
|
|
||||||
pause
|
|
||||||
|
|
||||||
set BIN=%~dp0bin\
|
set BIN=%~dp0bin\
|
||||||
set ARGS=--wf-tcp=443 --wf-udp=443,50000-50100 ^
|
set ARGS=--wf-tcp=443 --wf-udp=443,50000-50100 ^
|
||||||
@ -28,5 +26,3 @@ sc delete %SRVCNAME%
|
|||||||
sc create %SRVCNAME% binPath= "\"%BIN%winws.exe\" %ARGS%" DisplayName= "zapret DPI bypass : %SRVCNAME%" start= auto depend= "GoodbyeDPI"
|
sc create %SRVCNAME% binPath= "\"%BIN%winws.exe\" %ARGS%" DisplayName= "zapret DPI bypass : %SRVCNAME%" start= auto depend= "GoodbyeDPI"
|
||||||
sc description %SRVCNAME% "zapret DPI bypass software"
|
sc description %SRVCNAME% "zapret DPI bypass software"
|
||||||
sc start %SRVCNAME%
|
sc start %SRVCNAME%
|
||||||
|
|
||||||
pause
|
|
||||||
|
@ -5,41 +5,43 @@ chcp 65001 >nul
|
|||||||
|
|
||||||
set "arg=%1"
|
set "arg=%1"
|
||||||
if "%arg%" == "admin" (
|
if "%arg%" == "admin" (
|
||||||
echo Скрипт запущен с правами администратора
|
echo Restarted with admin rights
|
||||||
) else (
|
) else (
|
||||||
powershell -Command "Start-Process -FilePath '%~f0' -ArgumentList 'admin' -Verb RunAs"
|
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"%~f0 admin\"' -Verb RunAs"
|
||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
call check_updates.bat soft
|
||||||
|
echo:
|
||||||
|
|
||||||
set BIN_PATH=%~dp0bin\
|
set BIN_PATH=%~dp0bin\
|
||||||
|
|
||||||
:: Поиск .bat файлов в текущей категории, исключая файлы, которые начинаются с "service"
|
:: Searching for .bat files in current folder, except files that start with "service"
|
||||||
set "count=0"
|
set "count=0"
|
||||||
for %%f in (*.bat) do (
|
for %%f in (*.bat) do (
|
||||||
set "filename=%%~nxf"
|
set "filename=%%~nxf"
|
||||||
if /i not "!filename:~0,7!"=="service" (
|
if /i not "!filename:~0,7!"=="service" if /i not "!filename:~0,13!"=="check_updates" (
|
||||||
set /a count+=1
|
set /a count+=1
|
||||||
echo !count!. %%f
|
echo !count!. %%f
|
||||||
set "file!count!=%%f"
|
set "file!count!=%%f"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Выбираем файл
|
:: Choosing file
|
||||||
set "choice="
|
set "choice="
|
||||||
set /p "choice=Введите номер файла: "
|
set /p "choice=Input file index (number): "
|
||||||
|
|
||||||
if "!choice!"=="" goto :eof
|
if "!choice!"=="" goto :eof
|
||||||
|
|
||||||
set "selectedFile=!file%choice%!"
|
set "selectedFile=!file%choice%!"
|
||||||
if not defined selectedFile (
|
if not defined selectedFile (
|
||||||
echo Неверный выбор, завершение.
|
echo Wrong choice, exiting..
|
||||||
pause
|
pause
|
||||||
goto :eof
|
goto :eof
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Парсим аргументы (mergeargs: 2=start wf|1=wf argument|0=default)
|
:: Parsing args (mergeargs: 2=start wf|1=wf argument|0=default)
|
||||||
set "args="
|
set "args="
|
||||||
set "capture=0"
|
set "capture=0"
|
||||||
set "mergeargs=0"
|
set "mergeargs=0"
|
||||||
@ -106,7 +108,7 @@ for /f "tokens=*" %%a in ('type "!selectedFile!"') do (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Экзекьютим сервис со спаршенными аргументами
|
:: Creating service with parsed args
|
||||||
set ARGS=%args%
|
set ARGS=%args%
|
||||||
echo Final args: !ARGS!
|
echo Final args: !ARGS!
|
||||||
|
|
||||||
@ -117,5 +119,3 @@ sc delete %SRVCNAME%
|
|||||||
sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto
|
sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto
|
||||||
sc description %SRVCNAME% "zapret DPI bypass software"
|
sc description %SRVCNAME% "zapret DPI bypass software"
|
||||||
sc start %SRVCNAME%
|
sc start %SRVCNAME%
|
||||||
|
|
||||||
pause
|
|
||||||
|
@ -4,9 +4,9 @@ chcp 65001 >nul
|
|||||||
|
|
||||||
set "arg=%1"
|
set "arg=%1"
|
||||||
if "%arg%" == "admin" (
|
if "%arg%" == "admin" (
|
||||||
echo Скрипт запущен с правами администратора
|
echo Restarted with admin rights
|
||||||
) else (
|
) else (
|
||||||
powershell -Command "Start-Process -FilePath '%~f0' -ArgumentList 'admin' -Verb RunAs"
|
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"%~f0 admin\"' -Verb RunAs"
|
||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,5 +19,3 @@ net stop "WinDivert"
|
|||||||
sc delete "WinDivert"
|
sc delete "WinDivert"
|
||||||
net stop "WinDivert14"
|
net stop "WinDivert14"
|
||||||
sc delete "WinDivert14"
|
sc delete "WinDivert14"
|
||||||
|
|
||||||
pause
|
|
||||||
|
Loading…
Reference in New Issue
Block a user