Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checks for Cyrillic, spaces, and admin rights #12

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

Shurik244
Copy link

@Shurik244 Shurik244 commented Oct 9, 2024

There is more code, but in general it should help to automatically solve problems

I should probably make these checks as separate bat files and just call them, but I decided not to create unnecessary files.

discord.bat Outdated
)

:: Cyrillic check
echo %scriptPath% | findstr /r "[А-Яа-яЁё]" >nul
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange behavior. запрет-zapret-discord-youtube returns ErrorLevel 0, but абв-zapret-discord-youtube returns ErrorLevel 1

Copy link
Author

@Shurik244 Shurik244 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that we work UTF-8, because of what some letters he just ignores, and does not consider for сyrillic , it can be corrected only by using encoding 1251 (Windows-1251)
But then we will get something like this

РљРёСЂРёР "Р "ица - Р СѓСЃСЃРёР№ аР"С "Р°РРІРёС'.

The file should be saved in the same encoding, but I suppose that GitHub will probably convert it all to UTF-8
The code will be a little bit bigger, but in theory it guarantees us 100% validation of the Cyrillic characters

UPD: I wrote new code to detect Cyrillic, because playing around with encodings is just not my way

discord.bat Outdated
exit /b
)

:: Admin rights check
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For not-services .bat files admin rights actually not needed, optional for some cases. Same for discord_youtube.bat

Comment on lines 25 to 30
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Запуск от имени администратора...
powershell start -verb runas '%0'
exit /b
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting bat with admin privileges through powershell might be not a good idea.
Better solution would be to simply say that user should start with admin privileges and exit after pause

@@ -13,3 +45,6 @@ sc delete "%SRVCNAME%"
sc create "%SRVCNAME%" binPath= "%~dp0winws.exe %ARGS%" DisplayName= "zapret DPI bypass : winws1" start= auto
sc description "%SRVCNAME%" "zapret DPI bypass software"
sc start "%SRVCNAME%"

echo Серис был установлен и запущен.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot claim that the service was successfully launched. Just leave a pause without a message.

Comment on lines 38 to 39
echo Если какой либо файл не удаляется, перезагрузите пк.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot claim that the service was successfully removed. Just leave a pause without a message.

Fixed Cyrillic search in the path
@Shurik244 Shurik244 requested a review from Flowseal October 9, 2024 11:33
discord.bat Outdated
Comment on lines 16 to 23
setlocal enabledelayedexpansion
set "cyrillic_found=0"
for /l %%i in (0,1,127) do (
set "char=!scriptPath:~%%i,1!"
for %%c in (А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я) do (
if "!char!"=="%%c" set "cyrillic_found=1"
)
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's significantly increasing run time. On most devices script works with Cyrillic symbols in path. Let's not check it at all. Same for all others scripts

@Flowseal Flowseal merged commit 9e193a7 into Flowseal:main Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants