Skip to content

Instantly share code, notes, and snippets.

@xchwarze
Created August 25, 2023 22:37
Show Gist options
  • Save xchwarze/445c632cb0bd93dd2172a1244ad363fb to your computer and use it in GitHub Desktop.
Save xchwarze/445c632cb0bd93dd2172a1244ad363fb to your computer and use it in GitHub Desktop.
JetBrains Toolbox 2 - autoblock internet of tools
@echo off
setlocal enabledelayedexpansion
set "mainFolderPath=%LOCALAPPDATA%\Programs\"
set "foundDirectory="
rem Groncho-banner
echo JetBrains Toolbox 2 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"
rem I have no idea how to make this list outside!
if "!folderName!" neq "AndroidStudio" if "!folderName!" neq "Common" (
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" (
set "foundDirectory=%~1\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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment