【发布时间】:2016-09-03 21:22:27
【问题描述】:
我有一个批处理文件如下:
@echo off
REM <--Fetching installed service pack version and storing it in var-->
FOR /f "tokens=* " %%a in ('findstr /I "install.servicepack" ^< "C:\A\B\C\D.properties" ') DO SET temp=%%a
SET var=%temp:~22%
REM <-- I tested, correct value is getting assigned to var say 1.2.3-->
REM <--Next, I am changing the directory using CD, in which X, Y and Z is a fixed directory path and after that it is variable based upon %var% value
cd c:\X\Y\Z\%var%
echo %cd%
REM <-- I tested and directory is correctly set against cd c:\X\Y\Z\1.2.3
REM <--With in c:\X\Y\Z\%var% (c:\X\Y\Z\1.2.3), there is an exe called uninstaller.exe and I am executing it is below:
dir
ECHO MESSAGE: Starting Silent Uninstallation of ABC Package
uninstaller.exe -options -silent
ECHO MESSAGE: Finished Silent Uninstallation of ABC Package
设置:我在 Windows 上安装了 Jenkins,并通过 ANT 中的 sshexec 任务,我正在使用 cygwin openssh 在远程 Windows 机器中调用上述批处理文件。
问题:使用上述设置从 Jenkins 作业调用上述脚本时,它返回“远程命令失败,退出状态 127”。但是,如果我将 cd 中 %var% 的值硬编码为 cd c:\X\Y\Z\a.b.c 而不是作为 cd c:\X\Y\Z\%var% 传递,则脚本执行正常, IE。;直接更改具有确切路径的目录(cd C:\X.Y.Z.\1.2.3)。
我尝试了几种方法在更改目录后调用uninstaller.exe,但都没有成功。
请帮忙。
【问题讨论】:
标签: windows batch-file jenkins ant