cogconfig.bat 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. @echo off
  2. rem Licensed Materials - Property of IBM
  3. rem
  4. rem IBM Cognos Products: cnfg
  5. rem
  6. rem (C) Copyright IBM Corp. 2005, 2022
  7. rem
  8. rem US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. rem ---------------------------------------------------------------------------
  10. rem Shell script (Windows) to invoke jre and launch IBM Cognos Configuration.
  11. rem
  12. rem J_HOME is the location of the Java RE installation; if JAVA_HOME is
  13. rem defined, use it. Otherwise default to the local distribution.
  14. rem J_OPTS are the Java options to be passed into the JAVA VM (optional)
  15. rem ---------------------------------------------------------------------------
  16. rem
  17. rem The argument -java:{env | local} is not supported start from CA R2 11.1.2
  18. rem
  19. rem If the argument -java:{env | local} is present as first argument then the required JRE will be
  20. rem loaded: -java:env will force the script to look for JRE using JAVA_HOME environment variable.
  21. rem If not found then it will end by an error. The argument -java:local will force it to look
  22. rem for JRE within the local distribution. If not found then it will end by an error.
  23. rem Otherwise, the script will default by looking for a JRE using the JAVA_HOME environment
  24. rem variable, then if cannot find one, it will try to use the local distribution.
  25. rem Causes all changes made to environment variables to be local to this script
  26. rem up to the point where endlocal is encountered.
  27. setlocal
  28. rem Change directories to where this script lives
  29. CD /d %~dp0
  30. rem ----- Verify and Set Required Environment Variables -----------------------
  31. rem check if we need to run the local jre
  32. rem Shift the first argument: -java:local
  33. if "%1" == "-java:local" (shift & echo Option -java:local is not supported. Ignore it.)
  34. rem Try first the use of JAVA_HOME
  35. goto useEnvVar
  36. :useEnvVarOnly
  37. rem JAVA_HOME should be defined first.
  38. if "%JAVA_HOME%" == "" goto JavaHomeError
  39. set J_HOME=%JAVA_HOME%
  40. echo Looking for JRE in: %J_HOME%\bin...
  41. if exist "%J_HOME%\bin\java.exe" goto gotJava
  42. set J_HOME=%JAVA_HOME%\jre
  43. echo Looking for JRE in: %J_HOME%\jre\bin...
  44. if exist "%J_HOME%\bin\java.exe" goto gotJava
  45. :JavaHomeError
  46. echo You have specified the argument '-java:env'.
  47. echo However, the environment variable JAVA_HOME is not defined or incorrectly defined.
  48. echo Please define JAVA_HOME first before using the argument '-java:env'.
  49. goto finish
  50. rem Did not find a JRE in the local location, display error and exit.
  51. goto error
  52. :useEnvVar
  53. rem Shift the first argument: -java:env
  54. if "%1" == "-java:env" (shift & echo Option -java:env is not supported. Ignore it.)
  55. rem Using the distribution referred by JAVA_HOME because
  56. rem -java:local was NOT specified and the JAVA_HOME environment
  57. rem variable is defined.
  58. if "%JAVA_HOME%" == "" (
  59. set J_HOME=.
  60. ) else (
  61. set J_HOME=%JAVA_HOME%
  62. )
  63. echo Looking for JRE in: %J_HOME%\bin...
  64. if exist "%J_HOME%\bin\java.exe" goto gotJava
  65. if "%JAVA_HOME%" == "" (
  66. set J_HOME=..\ibm-jre\jre
  67. ) else (
  68. set J_HOME=%JAVA_HOME%\jre
  69. )
  70. echo Looking for JRE in: %J_HOME%\bin...
  71. if exist "%J_HOME%\bin\java.exe" goto gotJava
  72. rem Did not find a JRE in the environment variable's location.
  73. :error
  74. echo Could not find a JRE. Cannot run IBM Cognos Configuration.
  75. goto finish
  76. :gotJava
  77. rem ----- Prepare Appropriate Java Execution Commands -------------------------
  78. set _RUNJAVA="%J_HOME%\bin\java"
  79. set J_OPTS="-Dcom.ibm.jsse2.overrideDefaultTLS=true" %J_OPTS%
  80. rem ----- Enabling network preference. ----------------------------------------------
  81. rem The next command checks if IPv4 or IPv6 will be configured.
  82. rem Since network configuration is only checked at JVM initialization time, it must be done here
  83. if "%1" == "-ipv4" (shift & goto configureIPv4)
  84. if "%1" == "-IPv4" (shift & goto configureIPv4)
  85. if "%1" == "-ipv6" (shift & goto configureIPv6)
  86. if "%1" == "-IPv6" (shift & goto configureIPv6)
  87. goto ddraw
  88. :configureIPv4
  89. set J_OPTS="-Djava.net.preferIPv4Stack=true" %J_OPTS%
  90. goto ddraw
  91. :configureIPv6
  92. set J_OPTS="-Djava.net.preferIPv6Addresses=true" %J_OPTS%
  93. goto ddraw
  94. :ddraw
  95. rem uncomment to run Cognos Configuration with debug settings, so can attach a debugger
  96. rem set DEBUG_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=9091,server=y,suspend=y -Djava.compiler=NONE
  97. rem ----- Disabling DirectDraw. ----------------------------------------------
  98. rem The next command checks if the DirectDraw will be disabled.
  99. rem Disabling this DirectDraw might reduce the performance of the program that renders the image.
  100. rem It is recommended to disable the DirectDraw in the case the ConfigTool and some desktop
  101. rem icons flicker/flashes when started.
  102. if "%1" == "-noddraw" set DD_OPTS=-Dsun.java2d.noddraw=true
  103. if "%1" == "-noDDraw" set DD_OPTS=-Dsun.java2d.noddraw=true
  104. if not "%DD_OPTS%" == "" echo Disabling DirectDraw...
  105. set J_OPTS=%DD_OPTS% %J_OPTS% %DEBUG_OPTS%
  106. rem ----- Set Up The Runtime Classpath ----------------------------------------
  107. set CP=.;..\bin\cclcfgmcf_mcf.jar;cogconfig.jar;configcnfm.jar;..\bin\cogconfigi.jar;..\bin\cogcnfm.jar;..\bin\bcprov.jar;..\bin\bcpkix.jar;..\bin\dom4j-2.1.1.jar;..\bin\jaxen-1.1.1.jar;..\bin\cclcfgmcf.jar;..\bin\cclcfgapi.jar;..\bin\jcam_crypto.jar;..\bin\i18nj.jar;..\bin\icu4j.jar;..\bin\commons-httpclient-3.1.jar;..\bin\commons-codec-1.15.jar;..\bin\commons-logging-1.1.jar;..\bin\commons-logging-api-1.1.jar;..\bin\commons-logging-adapters-1.1.jar;..\bin\CognosIPF.jar;..\bin\slf4j-nop-1.7.23.jar;..\bin\log4j-api-2.17.1.jar;..\bin\log4j-core-2.17.1.jar;..\bin\log4j-over-slf4j-1.7.35.jar;..\bin\jcam_jni.jar;..\bin\jdxslt.jar;..\bin\jcam_config_test.jar;..\bin\cclcoreutil.jar;..\bin\CognosCCL4J.jar;..\configuration\utilities\config-util.jar
  108. @echo Using CLASSPATH: %CP%
  109. @echo Using J_HOME: %J_HOME%
  110. @echo Using J_OPTS: %J_OPTS%
  111. rem ----- Execute The Requested Command ---------------------------------------
  112. %_RUNJAVA% -cp %CP% %J_OPTS% CRConfig %1 %2 %3 %4 %5 %6 %7 %8 %9
  113. exit /b %ERRORLEVEL%
  114. :finish
  115. endlocal
  116. rem exit with error code 2: java home error
  117. exit /b 2