tags:

views:

25

answers:

1

I am developing a batch file to collect websphere products information, it seems to work fine except for some cases.

For some reason under some circumstances versionInfo.bat -maintenancePackages is called but the following code (check for manageprofiles.bat), it seems like it's returning from the :check section after calling versionInfo.

My Windows batch writing skills are very rusty, other improvements are welcome.

@echo off
SetLocal EnableDelayedExpansion

set tmpfile=%TEMP%\tmpdone.txt

echo. > %tmpfile%
For /F "eol= delims=| tokens=13" %%a in (%windir%\vpd.properties) Do (
set check=%%a
call :check
)
goto eof

:check
Set skip=No
For /F "eol= delims=|" %%a in (%tmpfile%) Do (
if "%%a" == "%check%" set skip=YES
)

if %skip% == YES goto eof
echo %check%>>%tmpfile%
if exist "%check%\bin\versionInfo.bat" "%check%\bin\versionInfo.bat" -maintenancePackages
echo %check%\bin\manageprofiles.bat
if exist "%check%\bin\manageprofiles.bat" "%check%\bin\manageprofiles.bat" -listProfiles
goto eof

:del
echo Done
del %tmpfile%

:eof
+1  A: 

You need to use call to run batch files from another batch file. Otherwise cmd won't return from the called one. So your code should read:

if exist "%check%\bin\versionInfo.bat" call "%check%\bin\versionInfo.bat" -maintenancePackages
echo %check%\bin\manageprofiles.bat
if exist "%check%\bin\manageprofiles.bat" call "%check%\bin\manageprofiles.bat" -listProfiles
goto :eof

(Also no need for a :eof jump label, you can just use the goto :eof special syntax to exit the batch file directly. I usually only use such a jump label if I need some cleanup to do first, but I name it differently then, to avoid confusion :-))

Joey
Oh, you figured that one out as well already. Ah well, I should read the comments ...
Joey