tags:

views:

264

answers:

2

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.

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%

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.

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?

+2  A: 

Does using

 call manageprofiles.bat

make any difference?

Mike Houston
Check if command extensions are turned on, too.
DDaviesBrackett
+5  A: 

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.

Graeme Perrow
When I turn them into call manageprofiles.bat, the script stops echoing the commands, effectively an @echo off. Is there a way to prevent this from happening without placing an @echo on after each call?
Chris Lieb
I'm assuming there's an @echo off at the top of manageprofiles.bat? If so, I don't think there is a way, other than adding @echo on at the end of manageprofiles.bat.
Graeme Perrow
Aha! So there is an @echo off at the top of manageprofiles.bat. I guess I'll just have to hack my way around it. Thanks.
Chris Lieb