Skip to content

Instantly share code, notes, and snippets.

@xchwarze
Last active August 25, 2023 22:37
Show Gist options
  • Save xchwarze/1382b2192b3c8bd005f26f179c1e8b11 to your computer and use it in GitHub Desktop.
Save xchwarze/1382b2192b3c8bd005f26f179c1e8b11 to your computer and use it in GitHub Desktop.
JetBrains Toolbox 1 block internet
@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
@ivypradeepcs
Copy link

What is this. where to add

@xchwarze
Copy link
Author

For block jetbrains products in W10/11. This is for use blocked serials.

@xchwarze
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment