我在使用Windows 2003系统,需要编写脚本来删除和创建WebSphere应用服务器中的配置文件。这需要我调用manageprofiles.bat命令两次,一次用于删除已有的配置文件,一次用于创建新的配置文件。
在批处理文件中,我有以下内容:
cd "C:\Program Files\IBM\WebSphere\AppServer\bin"
manageprofiles.bat -delete -profileName AppSrv01
rmdir /s /q ..\profiles\AppSrv01
manageprofiles.bat -create -templatePath ..\profileTemplates\default -profileName AppSrv01 -profilePath ..\profiles\AppSrv01
manageprofiles.bat文件以以下内容结尾:
set RC=%ERRORLEVEL%
@endlocal & exit /b %RC%
当我的批处理文件的第二行删除配置文件时出现错误(这种情况太常见了),manageprofiles.bat会输出错误消息并导致我的批处理文件终止。我不希望这种情况发生,因为我将在下一个命令中删除剩余的配置文件。阅读exit文档让我相信,在manageprofiles.bat中exit命令中的/b应该只会使manageprofiles.bat终止而不影响我的批处理文件。
我不想以任何方式触及manageprofiles.bat文件,因为我的更改可能会被后续更新撤销并再次破坏我的脚本。有没有什么办法在我的批处理文件中解决这个问题?