windows - 你如何拥有一个被调用的 bat 文件而不杀死它正在调用的 bat 文件?

标签 windows batch-file

我在 Windows 2003 系统上,需要编写脚本来删除和创建 WebSphere Application Server 中的配置文件。这需要我调用 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 终止而不影响我的 bat 文件。

我不想以任何方式触及 manageprofiles.bat 文件,因为我的更改可能会在以后的更新中恢复并再次破坏我的脚本。我可以在我的批处理文件中做些什么来解决这个问题吗?

最佳答案

将两次出现的“manageprofiles.bat”更改为“call manageprofiles.bat”。如果没有“调用”,执行将转移到 manageprofiles.bat 文件但不会返回。

关于windows - 你如何拥有一个被调用的 bat 文件而不杀死它正在调用的 bat 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1002830/

相关文章:

java - 创建关闭回显的命令行

windows - 如何让 Windows 记住我的密码 key ?

powershell - 如何以管理员身份并使用批处理文件中的参数运行 PowerShell?

batch-file - 批处理脚本在目录中搜索字符串并将结果保存到文件

windows - 批量转到丢失错误级别

batch-file - 我正在尝试制作一个自动更新的 .bat 程序

python - 需要安装PyOpenGL(Windows)

C# AutomationElement - 获取包括隐藏在内的所有托盘图标 (Windows 10)

python - Winreg Python、QueryInfoKey 给出的上次更改的日期/时间不正确?

ruby - 最佳批量大小 PostgreSQL 更新