Enhancements

More elegant start-up
This commit is contained in:
fridorin 2025-02-24 20:14:27 +03:00
parent 6874c0e429
commit f7a2220afd

View File

@ -1,23 +1,27 @@
@echo off @echo off
setlocal EnableDelayedExpansion setlocal EnableDelayedExpansion
chcp 65001 >nul chcp 65001 > nul
:: 65001 - UTF-8 :: 65001 - UTF-8
set "arg=%1" :: Admin rights check
if "%arg%" == "admin" ( net session >nul 2>&1
echo Restarted with admin rights if %errorLevel% neq 0 (
) else ( echo Requesting admin rights...
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"\"%~f0\" admin\"' -Verb RunAs" powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"\"%~f0\" admin\"' -Verb RunAs"
exit /b exit /b
) )
if "%1"=="admin" echo Started with admin rights
:: Main
cd /d "%~dp0" cd /d "%~dp0"
set BIN_PATH=%~dp0bin\
:: Checking for updates
call check_updates.bat soft call check_updates.bat soft
echo: echo:
set BIN_PATH=%~dp0bin\
:: Searching for .bat files in current folder, except files that start with "service" :: Searching for .bat files in current folder, except files that start with "service"
echo Pick one of the options:
set "count=0" set "count=0"
for %%f in (*.bat) do ( for %%f in (*.bat) do (
set "filename=%%~nxf" set "filename=%%~nxf"
@ -31,12 +35,11 @@ for %%f in (*.bat) do (
:: Choosing file :: Choosing file
set "choice=" set "choice="
set /p "choice=Input file index (number): " 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 Wrong choice, exiting.. echo Wrong choice, exiting...
pause pause
goto :eof goto :eof
) )
@ -107,11 +110,15 @@ for /f "tokens=*" %%a in ('type "!selectedFile!"') do (
:: Creating service with parsed args :: Creating service with parsed args
set ARGS=%args% set ARGS=%args%
echo Final args: !ARGS! echo Final args: !ARGS!
set SRVCNAME=zapret set SRVCNAME=zapret
net stop %SRVCNAME% net stop %SRVCNAME% >nul 2>&1
sc delete %SRVCNAME% sc delete %SRVCNAME% >nul 2>&1
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%
echo Service launched!
pause
endlocal