CPN commit

This commit is contained in:
2026-01-26 14:38:13 +01:00
parent 5366daa302
commit 8e68a1640b
2 changed files with 54 additions and 11 deletions

View File

@@ -6,7 +6,7 @@ REM Author: Flamur Veliqi (Netbie)
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
:MENU :MAIN_MENU
cls cls
echo Batchr Menu Launcher echo Batchr Menu Launcher
echo. echo.
@@ -19,16 +19,57 @@ echo Author: Flamur Veliqi (Netbie)
echo. echo.
echo ////////////////////////////////////////////////// echo //////////////////////////////////////////////////
echo. echo.
echo Scanning /files directory... echo Select script category:
echo.
echo [1] Own Scripts (from /files)
echo [2] Third-Party Scripts (from /files/third_party)
echo [0] Exit
echo.
echo //////////////////////////////////////////////////
echo.
set /p CATEGORY="Select option: "
if "%CATEGORY%"=="0" goto EXIT
if "%CATEGORY%"=="1" (
set "SCRIPT_PATH=files"
set "API_PATH=files"
set "CATEGORY_NAME=Own Scripts"
goto MENU
)
if "%CATEGORY%"=="2" (
set "SCRIPT_PATH=files/third_party"
set "API_PATH=files/third_party"
set "CATEGORY_NAME=Third-Party Scripts"
goto MENU
)
echo Invalid selection!
timeout /t 2 >nul
goto MAIN_MENU
:MENU
cls
echo Batchr Menu Launcher - !CATEGORY_NAME!
echo.
echo Powered by Weektab
echo Web: www.weektab.org
echo E-Mail: support@weektab.org
echo Project: Companas
echo Repository: git.weektab.org/companas/batchr
echo Author: Flamur Veliqi (Netbie)
echo.
echo //////////////////////////////////////////////////
echo.
echo Scanning /!SCRIPT_PATH! directory...
echo. echo.
REM Use Gitea API to list files in /files directory REM Use Gitea API to list files in selected directory
powershell -Command "$ProgressPreference = 'SilentlyContinue'; try { $response = Invoke-RestMethod -Uri 'https://git.weektab.org/api/v1/repos/companas/batchr/contents/files'; $batFiles = $response | Where-Object { $_.name -like '*.bat' } | Select-Object -ExpandProperty name | Sort-Object; if ($batFiles) { $batFiles | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII -NoNewline:$false } else { 'NONE' | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII } } catch { 'ERROR' | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII }" 2>nul powershell -Command "$ProgressPreference = 'SilentlyContinue'; try { $response = Invoke-RestMethod -Uri 'https://git.weektab.org/api/v1/repos/companas/batchr/contents/!API_PATH!'; $batFiles = $response | Where-Object { $_.name -like '*.bat' } | Select-Object -ExpandProperty name | Sort-Object; if ($batFiles) { $batFiles | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII -NoNewline:$false } else { 'NONE' | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII } } catch { 'ERROR' | Out-File '%TEMP%\repo_scripts.txt' -Encoding ASCII }" 2>nul
if not exist "%TEMP%\repo_scripts.txt" ( if not exist "%TEMP%\repo_scripts.txt" (
echo ERROR: Unable to access repository API echo ERROR: Unable to access repository API
pause pause
exit /b 1 goto MAIN_MENU
) )
REM Check for errors REM Check for errors
@@ -42,19 +83,19 @@ for /f "delims=" %%a in (%TEMP%\repo_scripts.txt) do (
if "%FIRST_LINE%"=="ERROR" ( if "%FIRST_LINE%"=="ERROR" (
echo ERROR: API request failed echo ERROR: API request failed
pause pause
exit /b 1 goto MAIN_MENU
) )
if "%FIRST_LINE%"=="NONE" ( if "%FIRST_LINE%"=="NONE" (
echo No .bat files found in /files directory! echo No .bat files found in /!SCRIPT_PATH! directory!
pause pause
exit /b 1 goto MAIN_MENU
) )
REM Get all script titles in one PowerShell call REM Get all script titles in one PowerShell call
echo Extracting list... echo Extracting list...
echo. echo.
powershell -Command "$ProgressPreference = 'SilentlyContinue'; try { $files = Get-Content '%TEMP%\repo_scripts.txt'; $results = @(); foreach ($file in $files) { if ($file -and $file -ne '' -and $file -ne 'NONE' -and $file -ne 'ERROR') { try { $url = 'https://git.weektab.org/companas/batchr/raw/branch/main/files/' + $file; $content = (Invoke-WebRequest -Uri $url -UseBasicParsing).Content; if ($content -match 'REM\s*===\s*(.+?)\s*===') { $results += $file + '|' + $matches[1] } else { $results += $file + '|' } } catch { $results += $file + '|' } } }; $results | Out-File '%TEMP%\repo_titles.txt' -Encoding ASCII } catch { }" 2>nul powershell -Command "$ProgressPreference = 'SilentlyContinue'; try { $files = Get-Content '%TEMP%\repo_scripts.txt'; $results = @(); foreach ($file in $files) { if ($file -and $file -ne '' -and $file -ne 'NONE' -and $file -ne 'ERROR') { try { $url = 'https://git.weektab.org/companas/batchr/raw/branch/main/!SCRIPT_PATH!/' + $file; $content = (Invoke-WebRequest -Uri $url -UseBasicParsing).Content; if ($content -match 'REM\s*===\s*(.+?)\s*===') { $results += $file + '|' + $matches[1] } else { $results += $file + '|' } } catch { $results += $file + '|' } } }; $results | Out-File '%TEMP%\repo_titles.txt' -Encoding ASCII } catch { }" 2>nul
REM Display menu REM Display menu
set INDEX=0 set INDEX=0
@@ -83,11 +124,12 @@ set TOTAL_SCRIPTS=%INDEX%
if %TOTAL_SCRIPTS%==0 ( if %TOTAL_SCRIPTS%==0 (
echo No .bat files found! echo No .bat files found!
pause pause
exit /b 1 goto MAIN_MENU
) )
echo. echo.
echo [R] Refresh List echo [R] Refresh List
echo [B] Back to Category Selection
echo [0] Exit echo [0] Exit
echo. echo.
echo ////////////////////////////////////////////////// echo //////////////////////////////////////////////////
@@ -95,6 +137,7 @@ echo.
set /p CHOICE="Select option: " set /p CHOICE="Select option: "
if /i "%CHOICE%"=="R" goto MENU if /i "%CHOICE%"=="R" goto MENU
if /i "%CHOICE%"=="B" goto MAIN_MENU
if "%CHOICE%"=="0" goto EXIT if "%CHOICE%"=="0" goto EXIT
REM Validate selection REM Validate selection
@@ -114,7 +157,7 @@ cls
echo /// Executing: !DISPLAY[%CHOICE%]! echo /// Executing: !DISPLAY[%CHOICE%]!
echo. echo.
set "SCRIPT_URL=https://git.weektab.org/companas/batchr/raw/branch/main/files/!SCRIPT_NAME[%CHOICE%]!" set "SCRIPT_URL=https://git.weektab.org/companas/batchr/raw/branch/main/!SCRIPT_PATH!/!SCRIPT_NAME[%CHOICE%]!"
set "TEMP_SCRIPT=%TEMP%\batch_script_%RANDOM%.bat" set "TEMP_SCRIPT=%TEMP%\batch_script_%RANDOM%.bat"
echo Downloading script... echo Downloading script...