08_17-AirCARE/bigwork/auto_fix_path.ps1

33 lines
1.1 KiB
PowerShell
Raw Normal View History

# PowerShell 自动修复 PATH 脚本
# 将此文件内容复制到 PowerShell 配置文件中
function Fix-Path {
Write-Host "🔧 自动修复 PATH 环境变量..." -ForegroundColor Yellow
# 检查并修复 Python Scripts 路径
$pythonScriptsPath = "C:\Users\马艺洁\AppData\Local\Programs\Python\Python312\Scripts"
if (-not ($env:PATH -like "*$pythonScriptsPath*")) {
Write-Host "✅ 添加正确的 Python Scripts 路径到 PATH" -ForegroundColor Green
$env:PATH = "$pythonScriptsPath;" + $env:PATH
}
# 修复其他格式错误
if ($env:PATH -like "*C:;Users*") {
Write-Host "✅ 修复 C:;Users 格式错误" -ForegroundColor Green
$env:PATH = $env:PATH.Replace('C:;Users', 'C:\Users')
}
if ($env:PATH -like "*;%S;stemRoot%*") {
Write-Host "✅ 修复 ;%S;stemRoot% 格式错误" -ForegroundColor Green
$env:PATH = $env:PATH.Replace(';%S;stemRoot%', ';%SystemRoot%')
}
Write-Host "✅ PATH 修复完成!现在可以直接使用 'uv' 命令" -ForegroundColor Green
}
# 自动执行修复
Fix-Path
# 创建快捷命令
alias uv-fix Fix-Path