I am on a Windows 2003 system and need to script the deletion and creation of a profile in WebSphere Application Server. This requires me to call manageprofiles.bat twice, once to delete the existing profile and once to create a new profile.
我在Windows 2003系统上,需要在WebSphere Application Server中编写删除和创建配置文件的脚本。这需要我两次调用manageprofiles.bat,一次删除现有配置文件,一次创建新配置文件。
In my batch file, I have the following:
在我的批处理文件中,我有以下内容:
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
The manageprofiles.bat file ends with:
manageprofiles.bat文件以以下结尾:
set RC=%ERRORLEVEL%
@endlocal & exit /b %RC%
When there is an error deleting the profile in the second line of my batch file (which happens way too often), manageprofiles.bat spits out an error message and causes my batch file to terminate. I don't want this to happen since I will just delete the remainder of the profile in the next command. Reading the documentation for exit leads me to believe that the /b in the exit command in manageprofiles.bat should cause just manageprofiles.bat to terminate without affecting my bat file.
如果在我的批处理文件的第二行中删除配置文件时出错(这种情况经常发生),manageprofiles.bat会发出错误消息并导致我的批处理文件终止。我不希望发生这种情况,因为我将在下一个命令中删除配置文件的其余部分。阅读退出文档会让我相信manageprofiles.bat中exit命令中的/ b应该导致manageprofiles.bat终止而不会影响我的bat文件。
I don't want to touch the manageprofiles.bat file in any way since my changes could get reverted by an update down the road and break my script again. Is there anything I can do in my batch file to fix this?
我不想以任何方式触摸manageprofiles.bat文件,因为我的更改可能会被更新恢复,并再次破坏我的脚本。我可以在批处理文件中做些什么来解决这个问题吗?
2 个解决方案
#1
Change both occurrences of "manageprofiles.bat" to "call manageprofiles.bat". Without the "call", execution is transferred to the manageprofiles.bat file but doesn't return.
将“manageprofiles.bat”的两次出现更改为“call manageprofiles.bat”。如果没有“调用”,执行将转移到manageprofiles.bat文件,但不会返回。
#2
Does using
call manageprofiles.bat
make any difference?
有什么区别?
#1
Change both occurrences of "manageprofiles.bat" to "call manageprofiles.bat". Without the "call", execution is transferred to the manageprofiles.bat file but doesn't return.
将“manageprofiles.bat”的两次出现更改为“call manageprofiles.bat”。如果没有“调用”,执行将转移到manageprofiles.bat文件,但不会返回。
#2
Does using
call manageprofiles.bat
make any difference?
有什么区别?