Files
HyperCLI/files/experimental/software-management-tool.bat

624 lines
15 KiB
Batchfile

@echo off
REM === Software Management Tool ===
chcp 65001 >nul
setlocal enabledelayedexpansion
:MENU
cls
echo ========================================
echo Software Management Tool
echo ========================================
echo.
echo [1] Scan installed software
echo [2] Check for updates only
echo [3] Install available updates
echo [4] Uninstall software
echo [5] Full system report
echo [0] Exit
echo.
echo ========================================
set /p CHOICE="Select option: "
if "%CHOICE%"=="1" goto SCAN_SOFTWARE
if "%CHOICE%"=="2" goto CHECK_UPDATES
if "%CHOICE%"=="3" goto INSTALL_UPDATES
if "%CHOICE%"=="4" goto UNINSTALL_SOFTWARE
if "%CHOICE%"=="5" goto FULL_REPORT
if "%CHOICE%"=="0" goto EXIT
goto MENU
:SCAN_SOFTWARE
cls
echo ========================================
echo Scan Installed Software
echo ========================================
echo.
echo Scanning system registry...
echo.
set "tempfile=%TEMP%\software_scan_%RANDOM%.tmp"
(
echo ========================================
echo INSTALLED SOFTWARE SCAN
echo Date: %date% %time%
echo Computer: %COMPUTERNAME%
echo ========================================
echo.
) > "%tempfile%"
REM 64-Bit Software
echo [1/3] Scanning 64-bit programs...
(
echo [64-BIT PROGRAMS]
echo ----------------------------------------
) >> "%tempfile%"
set COUNT64=0
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver (
echo !hasname! ^| Version: !hasver! >> "%tempfile%"
set /a COUNT64+=1
)
)
REM 32-Bit Software
echo [2/3] Scanning 32-bit programs...
(
echo.
echo [32-BIT PROGRAMS]
echo ----------------------------------------
) >> "%tempfile%"
set COUNT32=0
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver (
echo !hasname! ^| Version: !hasver! >> "%tempfile%"
set /a COUNT32+=1
)
)
REM User Programs
echo [3/3] Scanning user programs...
(
echo.
echo [USER PROGRAMS]
echo ----------------------------------------
) >> "%tempfile%"
set COUNTUSER=0
for /f "tokens=*" %%a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver (
echo !hasname! ^| Version: !hasver! >> "%tempfile%"
set /a COUNTUSER+=1
)
)
set /a TOTAL=COUNT64+COUNT32+COUNTUSER
(
echo.
echo ========================================
echo SUMMARY
echo ========================================
echo Total programs found: %TOTAL%
echo - 64-bit: %COUNT64%
echo - 32-bit: %COUNT32%
echo - User: %COUNTUSER%
echo ========================================
) >> "%tempfile%"
cls
type "%tempfile%"
echo.
set /p EXPORT="Export results to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%tempfile%" "Software_Scan"
del "%tempfile%" >nul 2>&1
pause
goto MENU
:CHECK_UPDATES
cls
echo ========================================
echo Check for Updates
echo ========================================
echo.
where winget >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Winget is not installed!
echo.
echo EXPLANATION:
echo Winget is Microsoft's package manager for Windows.
echo It is required to check and install updates.
echo.
echo SOLUTION:
echo 1. Open Microsoft Store
echo 2. Search for "App Installer"
echo 3. Install or Update it
echo.
pause
goto MENU
)
echo Checking for available updates...
echo This may take a moment...
echo.
set "tempfile=%TEMP%\updates_check_%RANDOM%.tmp"
(
echo ========================================
echo UPDATE CHECK REPORT
echo Date: %date% %time%
echo Computer: %COMPUTERNAME%
echo ========================================
echo.
) > "%tempfile%"
winget upgrade >> "%tempfile%" 2>&1
cls
type "%tempfile%"
echo.
set /p EXPORT="Export results to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%tempfile%" "Update_Check"
del "%tempfile%" >nul 2>&1
pause
goto MENU
:INSTALL_UPDATES
cls
echo ========================================
echo Install Updates
echo ========================================
echo.
where winget >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Winget is not installed!
echo.
echo EXPLANATION:
echo Winget is required to install updates.
echo.
echo SOLUTION:
echo Install "App Installer" from Microsoft Store.
echo.
pause
goto MENU
)
echo Checking for available updates...
echo.
winget upgrade | more
echo.
echo ========================================
echo.
echo [1] Update all programs
echo [2] Update specific program
echo [3] Update multiple programs (comma-separated)
echo [0] Cancel
echo.
set /p UPDATE_MODE="Select update mode: "
if "%UPDATE_MODE%"=="1" goto UPDATE_ALL
if "%UPDATE_MODE%"=="2" goto UPDATE_SPECIFIC
if "%UPDATE_MODE%"=="3" goto UPDATE_MULTIPLE
if "%UPDATE_MODE%"=="0" goto MENU
goto INSTALL_UPDATES
:UPDATE_ALL
cls
echo ========================================
echo Updating All Programs
echo ========================================
echo.
echo WARNING: This will update all available programs.
echo This process may take several minutes.
echo.
set /p CONFIRM="Continue? (Y/N): "
if /i not "%CONFIRM%"=="Y" goto INSTALL_UPDATES
echo.
echo Starting update process...
echo.
set "logfile=%TEMP%\update_all_%RANDOM%.log"
winget upgrade --all > "%logfile%" 2>&1
cls
type "%logfile%"
echo.
echo ========================================
echo Update process completed!
echo ========================================
echo.
set /p EXPORT="Export log to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%logfile%" "Update_All_Log"
del "%logfile%" >nul 2>&1
pause
goto MENU
:UPDATE_SPECIFIC
cls
echo ========================================
echo Update Specific Program
echo ========================================
echo.
echo Enter the exact program ID or name from the list above.
echo Example: Microsoft.VisualStudioCode
echo.
set /p PROGRAM_ID="Program ID/Name: "
if "%PROGRAM_ID%"=="" (
echo [ERROR] No program specified!
pause
goto INSTALL_UPDATES
)
echo.
echo Updating: %PROGRAM_ID%
echo.
set "logfile=%TEMP%\update_single_%RANDOM%.log"
winget upgrade "%PROGRAM_ID%" > "%logfile%" 2>&1
type "%logfile%"
if %errorlevel% neq 0 (
echo.
echo [ERROR] Update failed!
echo.
echo POSSIBLE REASONS:
echo - Program ID/Name incorrect
echo - Program not found in winget
echo - No update available for this program
echo - Permission denied
echo.
)
echo.
set /p EXPORT="Export log to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%logfile%" "Update_Single_Log"
del "%logfile%" >nul 2>&1
echo.
set /p ANOTHER="Update another program? (Y/N): "
if /i "%ANOTHER%"=="Y" goto UPDATE_SPECIFIC
goto MENU
:UPDATE_MULTIPLE
cls
echo ========================================
echo Update Multiple Programs
echo ========================================
echo.
echo Enter program IDs or names separated by commas.
echo Example: Firefox, Chrome, VSCode
echo.
set /p PROGRAMS="Programs (comma-separated): "
if "%PROGRAMS%"=="" (
echo [ERROR] No programs specified!
pause
goto INSTALL_UPDATES
)
echo.
echo Updating selected programs...
echo.
set "logfile=%TEMP%\update_multi_%RANDOM%.log"
(
echo ========================================
echo MULTIPLE PROGRAM UPDATE LOG
echo Date: %date% %time%
echo ========================================
echo.
) > "%logfile%"
for %%p in (%PROGRAMS%) do (
echo ---------------------------------------- >> "%logfile%"
echo Updating: %%p >> "%logfile%"
echo ---------------------------------------- >> "%logfile%"
winget upgrade "%%p" >> "%logfile%" 2>&1
echo. >> "%logfile%"
)
cls
type "%logfile%"
echo.
echo ========================================
echo All updates completed!
echo ========================================
echo.
set /p EXPORT="Export log to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%logfile%" "Update_Multi_Log"
del "%logfile%" >nul 2>&1
pause
goto MENU
:UNINSTALL_SOFTWARE
cls
echo ========================================
echo Uninstall Software
echo ========================================
echo.
where winget >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Winget is not installed!
echo.
echo EXPLANATION:
echo Winget is required for safe uninstallation.
echo.
echo ALTERNATIVE:
echo Use Windows Settings - Apps - Installed apps
echo.
pause
goto MENU
)
echo Listing installed software...
echo.
winget list | more
echo.
echo ========================================
echo.
echo [1] Uninstall single program
echo [2] Uninstall multiple programs (comma-separated)
echo [0] Cancel
echo.
set /p UNINSTALL_MODE="Select mode: "
if "%UNINSTALL_MODE%"=="1" goto UNINSTALL_SINGLE
if "%UNINSTALL_MODE%"=="2" goto UNINSTALL_MULTIPLE
if "%UNINSTALL_MODE%"=="0" goto MENU
goto UNINSTALL_SOFTWARE
:UNINSTALL_SINGLE
cls
echo ========================================
echo Uninstall Single Program
echo ========================================
echo.
set /p PROGRAM="Enter program ID or name: "
if "%PROGRAM%"=="" (
echo [ERROR] No program specified!
pause
goto UNINSTALL_SOFTWARE
)
echo.
echo WARNING: This will uninstall: %PROGRAM%
echo.
set /p CONFIRM="Are you sure? (Y/N): "
if /i not "%CONFIRM%"=="Y" goto UNINSTALL_SOFTWARE
echo.
echo Uninstalling %PROGRAM%...
echo.
winget uninstall "%PROGRAM%"
if %errorlevel% neq 0 (
echo.
echo [ERROR] Uninstallation failed!
echo.
echo POSSIBLE REASONS:
echo - Program ID/Name incorrect
echo - Program not found
echo - Permission denied (try running as Administrator)
echo - Program requires manual uninstallation
echo.
)
echo.
set /p ANOTHER="Uninstall another program? (Y/N): "
if /i "%ANOTHER%"=="Y" goto UNINSTALL_SINGLE
goto MENU
:UNINSTALL_MULTIPLE
cls
echo ========================================
echo Uninstall Multiple Programs
echo ========================================
echo.
echo Enter program IDs or names separated by commas.
echo Example: Firefox, Chrome, VSCode
echo.
set /p PROGRAMS="Programs (comma-separated): "
if "%PROGRAMS%"=="" (
echo [ERROR] No programs specified!
pause
goto UNINSTALL_SOFTWARE
)
echo.
echo WARNING: This will uninstall the following programs:
echo %PROGRAMS%
echo.
set /p CONFIRM="Are you sure? (Y/N): "
if /i not "%CONFIRM%"=="Y" goto UNINSTALL_SOFTWARE
echo.
echo Uninstalling selected programs...
echo.
for %%p in (%PROGRAMS%) do (
echo ========================================
echo Uninstalling: %%p
echo ========================================
winget uninstall "%%p"
echo.
)
echo.
echo ========================================
echo Uninstallation completed!
echo ========================================
pause
goto MENU
:FULL_REPORT
cls
echo ========================================
echo Full System Report
echo ========================================
echo.
echo Generating comprehensive report...
echo This may take a moment...
echo.
set "tempfile=%TEMP%\full_report_%RANDOM%.tmp"
(
echo ========================================
echo FULL SYSTEM REPORT
echo Date: %date% %time%
echo Computer: %COMPUTERNAME%
echo User: %USERNAME%
echo ========================================
echo.
echo.
echo [INSTALLED SOFTWARE - 64-BIT]
echo ----------------------------------------
) > "%tempfile%"
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver echo !hasname! ^| Version: !hasver! >> "%tempfile%"
)
(
echo.
echo [INSTALLED SOFTWARE - 32-BIT]
echo ----------------------------------------
) >> "%tempfile%"
for /f "tokens=*" %%a in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver echo !hasname! ^| Version: !hasver! >> "%tempfile%"
)
(
echo.
echo [INSTALLED SOFTWARE - USER]
echo ----------------------------------------
) >> "%tempfile%"
for /f "tokens=*" %%a in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 2^>nul') do (
set "hasname="
set "hasver="
for /f "skip=2 tokens=2*" %%b in ('reg query "%%a" /v DisplayName 2^>nul') do set "hasname=%%c"
for /f "skip=2 tokens=2*" %%d in ('reg query "%%a" /v DisplayVersion 2^>nul') do set "hasver=%%e"
if defined hasname if defined hasver echo !hasname! ^| Version: !hasver! >> "%tempfile%"
)
(
echo.
echo.
echo ========================================
echo AVAILABLE UPDATES
echo ========================================
echo.
) >> "%tempfile%"
where winget >nul 2>&1
if %errorlevel% equ 0 (
winget upgrade >> "%tempfile%" 2>&1
) else (
echo [NOTE] Winget is not installed. >> "%tempfile%"
echo Cannot check for updates. >> "%tempfile%"
)
echo ======================================== >> "%tempfile%"
cls
type "%tempfile%"
echo.
set /p EXPORT="Export report to file? (Y/N): "
if /i "%EXPORT%"=="Y" call :EXPORT_FILE "%tempfile%" "Full_System_Report"
del "%tempfile%" >nul 2>&1
pause
goto MENU
:EXPORT_FILE
set "source=%~1"
set "prefix=%~2"
set "timestamp=%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
set "timestamp=%timestamp: =0%"
set "output=%USERPROFILE%\Desktop\%prefix%_%timestamp%.txt"
copy "%source%" "%output%" >nul
if %errorlevel% neq 0 (
echo.
echo [ERROR] Export failed!
echo.
echo POSSIBLE REASONS:
echo - Desktop folder not accessible
echo - Insufficient permissions
echo - Disk full
echo.
echo Trying alternative location...
set "output=%TEMP%\%prefix%_%timestamp%.txt"
copy "%source%" "!output!" >nul
)
echo.
echo [OK] File saved to:
echo %output%
echo.
set /p OPEN_FILE="Open file now? (Y/N): "
if /i "%OPEN_FILE%"=="Y" start notepad "%output%"
goto :EOF
:EXIT
cls
echo Exiting...
timeout /t 1 /nobreak >nul
exit