- 拓展/: MCP配置向导、PowerShell工具、mcp-auto-loader 纳入版本管理 - guide.html: badges 从模糊 "90+" 改为精确 "92 Skills | 18 Agents | 34 Hooks"
60 lines
1.9 KiB
Batchfile
60 lines
1.9 KiB
Batchfile
@echo off
|
|
chcp 65001 >nul
|
|
setlocal enabledelayedexpansion
|
|
|
|
echo.
|
|
echo ========================================================
|
|
echo Create Admin PowerShell Shortcut for Claude Code
|
|
echo ========================================================
|
|
echo.
|
|
|
|
:: Check admin privileges
|
|
net session >nul 2>&1
|
|
if %errorlevel% neq 0 (
|
|
echo [!] Requesting administrator privileges...
|
|
powershell -Command "Start-Process '%~f0' -Verb RunAs"
|
|
exit /b
|
|
)
|
|
|
|
:: Detect PowerShell path
|
|
set "PS_PATH="
|
|
for %%p in (
|
|
"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
|
|
"%ProgramFiles%\PowerShell\7\pwsh.exe"
|
|
"%ProgramFiles(x86)%\PowerShell\7\pwsh.exe"
|
|
) do (
|
|
if exist %%p (
|
|
set "PS_PATH=%%p"
|
|
goto :ps_found
|
|
)
|
|
)
|
|
|
|
:ps_found
|
|
if "!PS_PATH!" == "" (
|
|
echo [ERROR] PowerShell not found
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [OK] PowerShell: !PS_PATH!
|
|
|
|
:: Create admin shortcut
|
|
set "SHORTCUT_PATH=%USERPROFILE%\Desktop\Claude Code (Admin Terminal).lnk"
|
|
|
|
powershell -NoProfile -Command "$WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%SHORTCUT_PATH%'); $Shortcut.TargetPath = '!PS_PATH!'; $Shortcut.Arguments = '-NoExit -Command \"Write-Host ''Claude Code Admin Terminal Ready'' -ForegroundColor Green; Write-Host ''Type: claude'' -ForegroundColor Yellow\"'; $Shortcut.WorkingDirectory = '%USERPROFILE%'; $Shortcut.Description = 'PowerShell with Admin Rights for Claude Code'; $Shortcut.Save(); $bytes = [System.IO.File]::ReadAllBytes('%SHORTCUT_PATH%'); $bytes[0x15] = $bytes[0x15] -bor 0x20; [System.IO.File]::WriteAllBytes('%SHORTCUT_PATH%', $bytes)"
|
|
|
|
if exist "%SHORTCUT_PATH%" (
|
|
echo.
|
|
echo [SUCCESS] Admin terminal shortcut created!
|
|
echo.
|
|
echo [Usage]
|
|
echo 1. Double-click "Claude Code (Admin Terminal)" on desktop
|
|
echo 2. Type: claude
|
|
echo 3. Claude Code will run with administrator privileges
|
|
echo.
|
|
) else (
|
|
echo [ERROR] Failed to create shortcut
|
|
)
|
|
|
|
pause
|