@echo off setlocal REM 运行 "where git" 命令获取 git.exe 的路径 for /f "delims=" %%I in ('where git') do set "git_path=%%~dpI" REM 获取 git.exe 所在的文件夹路径 for %%I in ("%git_path%..") do set "git_folder=%%~fI" REM 构建目标路径 set "target_path=%git_folder%\bin\bash.exe" REM 将路径中的单反斜杠替换为双反斜杠 set "target_path=%target_path:\=\\%" echo %target_path% pause