169 lines
5.1 KiB
Batchfile
169 lines
5.1 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
title AZ Computer Guru - ClaudeTools Laptop Fix
|
|
color 0B
|
|
|
|
rem ============================================================
|
|
rem ClaudeTools - Laptop Fix (Howard)
|
|
rem ------------------------------------------------------------
|
|
rem 1) Installs the programs Claude needs (git, node, claude,
|
|
rem python, sops).
|
|
rem 2) Stops the "Claude hangs then closes when opened from the
|
|
rem claudetools folder" bug by disabling the grepai MCP
|
|
rem server (its binary, grepai.exe, is missing on this PC).
|
|
rem 3) Makes a desktop launcher that stays open on errors.
|
|
rem
|
|
rem Safe to run more than once. Targets C:\claudetools.
|
|
rem ============================================================
|
|
|
|
set "BASE=C:\claudetools"
|
|
set "SCRIPT_DIR=%~dp0"
|
|
set "NEEDS_RESTART=0"
|
|
|
|
echo ============================================
|
|
echo ClaudeTools - Laptop Fix
|
|
echo ============================================
|
|
echo.
|
|
echo Installs required programs and stops the
|
|
echo hang-then-close problem when opening Claude.
|
|
echo.
|
|
echo Press any key to start, or close to cancel.
|
|
pause >nul
|
|
|
|
echo.
|
|
echo [1/4] Installing required programs...
|
|
|
|
where winget >nul 2>&1
|
|
if errorlevel 1 echo [WARNING] winget missing. Install "App Installer" from the Microsoft Store, then re-run.
|
|
|
|
rem --- git (also provides Git Bash, used by the repo) ---
|
|
where git >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [..] installing git...
|
|
winget install --id Git.Git -e --accept-package-agreements --accept-source-agreements
|
|
set "NEEDS_RESTART=1"
|
|
) else (
|
|
echo [OK] git
|
|
)
|
|
|
|
rem --- node (Claude Code runs on Node) ---
|
|
where node >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [..] installing Node.js LTS...
|
|
winget install --id OpenJS.NodeJS.LTS -e --accept-package-agreements --accept-source-agreements
|
|
set "NEEDS_RESTART=1"
|
|
) else (
|
|
echo [OK] node
|
|
)
|
|
|
|
rem --- python ---
|
|
where py >nul 2>&1
|
|
if errorlevel 1 (
|
|
where python >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [..] installing Python...
|
|
winget install --id Python.Python.3.12 -e --accept-package-agreements --accept-source-agreements
|
|
set "NEEDS_RESTART=1"
|
|
) else (
|
|
echo [OK] python
|
|
)
|
|
) else (
|
|
echo [OK] python
|
|
)
|
|
|
|
rem --- sops (vault decryption) ---
|
|
where sops >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo [..] installing SOPS...
|
|
winget install --id Mozilla.sops -e --accept-package-agreements --accept-source-agreements
|
|
) else (
|
|
echo [OK] sops
|
|
)
|
|
|
|
if "%NEEDS_RESTART%"=="1" (
|
|
echo.
|
|
echo ============================================
|
|
echo New programs were installed. CLOSE this
|
|
echo window and RUN THIS SCRIPT AGAIN so they
|
|
echo are on PATH. The second run finishes up.
|
|
echo ============================================
|
|
echo.
|
|
pause
|
|
exit /b 0
|
|
)
|
|
|
|
echo.
|
|
echo [2/4] Installing / updating Claude Code...
|
|
call npm install -g @anthropic-ai/claude-code
|
|
if errorlevel 1 (
|
|
echo [WARNING] Claude Code install reported an error - continuing.
|
|
) else (
|
|
echo [OK] Claude Code installed/updated
|
|
)
|
|
|
|
echo.
|
|
echo [3/4] Installing grepai + configuring MCP ^(stops the hang^)...
|
|
if not exist "%BASE%" (
|
|
echo [WARNING] %BASE% not found. Make sure ClaudeTools is at %BASE%, then re-run.
|
|
goto :launcher
|
|
)
|
|
|
|
rem --- install grepai.exe shipped alongside this script ---
|
|
if exist "%SCRIPT_DIR%grepai.exe" (
|
|
copy /Y "%SCRIPT_DIR%grepai.exe" "%BASE%\grepai.exe" >nul
|
|
echo [OK] grepai.exe copied to %BASE%
|
|
) else (
|
|
echo [..] grepai.exe not in this package - will disable the MCP server instead
|
|
)
|
|
|
|
if not exist "%BASE%\.claude" (
|
|
echo [WARNING] %BASE%\.claude not found.
|
|
echo Make sure ClaudeTools is at %BASE%, then re-run.
|
|
goto :launcher
|
|
)
|
|
|
|
set "SL=%BASE%\.claude\settings.local.json"
|
|
if exist "%SL%" copy /Y "%SL%" "%SL%.bak" >nul
|
|
|
|
if exist "%BASE%\grepai.exe" (
|
|
> "%SL%" echo {
|
|
>>"%SL%" echo "env": { "CLAUDETOOLS_ROOT": "C:/claudetools" }
|
|
>>"%SL%" echo }
|
|
echo [OK] grepai.exe present - left enabled
|
|
) else (
|
|
> "%SL%" echo {
|
|
>>"%SL%" echo "env": { "CLAUDETOOLS_ROOT": "C:/claudetools" },
|
|
>>"%SL%" echo "disabledMcpjsonServers": ["grepai"]
|
|
>>"%SL%" echo }
|
|
echo [OK] grepai MCP server disabled - Claude will no longer hang
|
|
)
|
|
if exist "%SL%.bak" echo ^(old settings backed up to settings.local.json.bak^)
|
|
|
|
:launcher
|
|
echo.
|
|
echo [4/4] Creating desktop launcher...
|
|
set "SHORTCUT=%USERPROFILE%\Desktop\ClaudeTools.bat"
|
|
> "%SHORTCUT%" echo @echo off
|
|
>>"%SHORTCUT%" echo title ClaudeTools - AZ Computer Guru
|
|
>>"%SHORTCUT%" echo cd /d C:\claudetools
|
|
>>"%SHORTCUT%" echo claude %%*
|
|
>>"%SHORTCUT%" echo if errorlevel 1 (
|
|
>>"%SHORTCUT%" echo echo.
|
|
>>"%SHORTCUT%" echo echo [WARNING] Claude exited with an error - window kept open so you can read it.
|
|
>>"%SHORTCUT%" echo pause
|
|
>>"%SHORTCUT%" echo ^)
|
|
echo [OK] created %SHORTCUT%
|
|
|
|
echo.
|
|
echo ============================================
|
|
echo Done
|
|
echo ============================================
|
|
echo.
|
|
where claude >nul 2>&1 && claude --version || echo [WARNING] claude not on PATH yet - open a NEW window.
|
|
echo.
|
|
echo Open a NEW window, then double-click "ClaudeTools"
|
|
echo on your Desktop. It should open without hanging.
|
|
echo.
|
|
pause
|
|
endlocal
|