PDA

View Full Version : how to check target system has certain software installed already?



betty1
05-19-2004, 03:31 PM
in my installscript project, i want to check if target system has follwoing software installed: J2SDK 1_4_2_04, jakarta-Tomcat5.0.19 and JMF 2_1_1e? is there any way i can do it? thanks
betty

sogilvie
05-19-2004, 04:56 PM
Betty,

what you want to do is to check the registry to see if the products exits, ie. I check for a certain JRE:

/*------------------------------------------------------------------------*\
* *
* Function: InstallJre *
* *
* Descrip: This returns 1 if JRE needs to be installed or 0 if not *
* Misc: *
* *
\*------------------------------------------------------------------------*/
function InstallJre()

STRING szCurrFileVer, szRegKey, szRegVarName, szTempStr;
NUMBER nvSize, nvType, nReturn;

begin

// get the current installed version number for Jre 1.3.0
szRegKey = "SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.3";
szRegVarName = "JavaHome";

nvType = REGDB_STRING;

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBKeyExist(szRegKey) < 0) then
szJavaHome = PROGRAMFILES ^ "JavaSoft\\JRE\\1.3";
return 1;
elseif (RegDBGetKeyValueEx(szRegKey, "MicroVersion", nvType, szTempStr, nvSize) < 0) then
szJavaHome = PROGRAMFILES ^ "JavaSoft\\JRE\\1.3";
return 1;
elseif ( StrCompare(szTempStr, "0") != 0 ) then
return 1;
elseif ( RegDBGetKeyValueEx(szRegKey, szRegVarName, nvType, szJavaHome, nvSize) < 0 ) then
return 1;
else
return 0;
endif;
end;

call it by:

/* see if we need to install JRE 1.3 */
nReturn = InstallJre();
if nReturn = 1 then
bInstallJre = TRUE;
endif;

hope that helps...

betty1
05-20-2004, 04:00 PM
thank you very much for your help. It works fine.
best regards,
betty