How do you have a named bat file that doesn't kill it by invoking the bat file?

I am on a Windows 2003 system and must script to delete and create a profile in WebSphere Application Server. This requires me to call manageprofiles.bat twice, once to delete an existing profile and once to create a new profile.

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:

 set RC=%ERRORLEVEL% @endlocal & exit /b %RC% 

If the delete profile error in the second line of my batch file fails (which happens too often), manageprofiles.bat gives an error message and causes my batch file to terminate. I do not want this to happen, as I just delete the rest of the profile in the next command. Reading the exit documentation leads me to think that the / b command in the exit command in the manageprofiles.bat file should cause just manageprofiles.bat to complete without prejudice to my bat file.

I do not want to touch the manageprofiles.bat file in any way, since my changes can be returned by updating on the way and breaking my script again. Is there anything I can do in my batch file to fix this?

+4
source share
2 answers

Change both occurrences of "manageprofiles.bat" to "call manageprofiles.bat". Without a β€œcall”, execution is transferred to the manageprofiles.bat file, but is not returned.

+8
source

Does it use

  call manageprofiles.bat 

has the meaning?

+4
source

Source: https://habr.com/ru/post/1286308/


All Articles