我正在编写一个批处理脚本来自动推拉到git (因为我不想在这里讨论的原因)。
这个脚本在我的电脑上运行得很好,但在我同事的电脑上却不起作用。到了MessageBox.exe问你是否要提交的部分,但是在他的PC上,我得到了一个错误
代码语言:javascript复制find : yes : Cannot find the specified file or directory.在我的电脑上,脚本工作得很好。我们有相同的操作系统等等,所以我不知道从哪里开始。
我知道这是一个非常松散的问题,我对Windows脚本很陌生,但是任何提示都会很好。
谢谢!
代码语言:javascript复制@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
call %~dp0%config.bat
SET scriptPath=%~dp0
SET file=%1
echo Saving current working directory
SET cwd=%cd%
echo Loading SSH key (%SSHKey%)
START "" "%puttyLocation%pageant.exe" "%SSHKey%"
echo Moving to library directory (%libDir%)
cd /D %libDir%
echo Pulling from git....
git pull %remoteName%
echo Changing back to the original directory (%cwd%)
cd /D %cwd%
%easyPCLocation% %file%
echo Moving to library directory (%libDir%)
cd /D %libDir%
git status --porcelain
git status --porcelain > %scriptPath%temp.txt
for %%A in (%scriptPath%temp.txt) do if %%~zA==0 (
echo.No changes to your library have been made.
) ELSE (
echo Changes have been made to your library. Please push them to git now.
!scriptPath!MessageBox.exe "Changes have been made to your library. Please push them to git now.\n\nWould you like up push to git?" "Library updates detected!" YesNo Question Button1 > %scriptPath%temp2.txt
find "yes" !scriptPath!temp2.txt && (
!scriptPath!InputBox.exe "Commit message:" "Updating git..." > !scriptPath!temp2.txt
set /p commitMessage=
echo !commitMessage!
git add .
git commit -a -m "!commitMessage!"
git push
) || (
echo REMEMBER to push changes manually!!!!
)
del !scriptPath!temp2.txt
)
del %scriptPath%temp.txt
echo Changing back to the original directory (%cwd%)
cd /D %cwd%
endlocal
!