Last active
August 25, 2023 22:37
-
-
Save xchwarze/1382b2192b3c8bd005f26f179c1e8b11 to your computer and use it in GitHub Desktop.
JetBrains Toolbox 1 block internet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
set "mainFolderPath=%LOCALAPPDATA%\JetBrains\Toolbox\apps\" | |
set "subfolderName=ch-0" | |
set "foundDirectory=" | |
rem Groncho-banner | |
echo JetBrains Toolbox autoblock - by DSR! | |
echo git: https://github.com/xchwarze | |
echo ---------------------------------------- | |
echo. | |
rem Check for administrator permissions. | |
1>nul 2>nul reg query HKU\S-1-5-19 || ( | |
echo [-] You must run the command prompt as administrator to run this script. | |
ping 127.0.0.1 > NUL 2>&1 | |
exit /b 1 | |
) | |
call :iterateFolders "%mainFolderPath%" | |
if not defined foundDirectory ( | |
echo [-] No valid directory found. | |
) | |
echo [*] Script complete. | |
ping 127.0.0.1 > NUL 2>&1 | |
exit /b | |
:iterateFolders | |
for /d %%i in ("%~1*") do ( | |
set "folderName=%%~nxi" | |
set "subfolderPath=%%i\%subfolderName%" | |
rem I have no idea how to make this list outside! | |
if "!folderName!" neq "AndroidStudio" if "!folderName!" neq "Toolbox" ( | |
echo [*] App: !folderName! | |
call :checkDirectory "!subfolderPath!" | |
) | |
) | |
exit /b | |
:checkDirectory | |
rem Check if ch-0 directory exists and does not end with .plugins | |
if exist "%~1" ( | |
for /f "delims=" %%d in ('dir /b /ad "%~1\*" ^| findstr /v ".plugins$"') do ( | |
set "foundDirectory=%~1\%%d\bin" | |
call :execute | |
) | |
) else ( | |
echo [-] Subfolder not found | |
) | |
exit /b | |
:execute | |
echo [*] Folder: !subfolderPath! | |
set "executableFile=" | |
if exist "%foundDirectory%" ( | |
for /f %%x in ('dir /b "!foundDirectory!\*64.exe"') do ( | |
set "executableFile=!foundDirectory!\%%x" | |
goto :executeFile | |
) | |
) else ( | |
echo [-] Main exe not found | |
) | |
echo [-] No executable file found in "!foundDirectory!" ending with "64.exe". | |
echo. | |
exit /b | |
:executeFile | |
echo [+] Block main exe | |
netsh advfirewall firewall delete rule name="Block !folderName!" | |
netsh advfirewall firewall add rule name="Block !folderName!" dir=out action=block program="%executableFile%" | |
echo. | |
exit /b |
For block jetbrains products in W10/11. This is for use blocked serials.
for JetBrains Toolbox use this version https://gist.github.com/xchwarze/445c632cb0bd93dd2172a1244ad363fb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this. where to add