-
Notifications
You must be signed in to change notification settings - Fork 567
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
Conversation
Added some messages for users
discord.bat
Outdated
) | ||
|
||
:: Cyrillic check | ||
echo %scriptPath% | findstr /r "[А-Яа-яЁё]" >nul |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
service_discord.bat
Outdated
net session >nul 2>&1 | ||
if %errorLevel% neq 0 ( | ||
echo Запуск от имени администратора... | ||
powershell start -verb runas '%0' | ||
exit /b | ||
) |
There was a problem hiding this comment.
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
service_discord_youtube.bat
Outdated
@@ -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 Серис был установлен и запущен. |
There was a problem hiding this comment.
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.
service_remove.bat
Outdated
echo Если какой либо файл не удаляется, перезагрузите пк. |
There was a problem hiding this comment.
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
discord.bat
Outdated
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" | ||
) | ||
) |
There was a problem hiding this comment.
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
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.