PDA

View Full Version : RegistryService cant find installed product



drostowsky
01-24-2006, 04:47 PM
I have the following function below called when I begin an install. I want to do a multi-instance install so Im trying to find out the instance number of my product to find if it has been installed before. When I run this code, I get:

The instance of the product with a UID of ERROR: unable to find assembly with id bean79 is: -1

OK, so I hardcode in the UID, and then is still get productInstance coming back as -1.

Im using Windows XP, so I went to windows/ and found vpd.properties. I dont see any registry entry in there for my installed product. ?!!

Help!!

=================================================

try
{
LogService logService=(LogService)arg0.getServices().getService(LogService.NAME);
//logService.setLogOutput("c:\\temp\\log.txt");
logService.writeToOutput("onBeginInstall");

String uid = arg0.getServices().resolveString("$P($P(beanId).key.UID)");

// Construct appropriate SoftwareObjectKey for the product in question
SoftwareObjectKey sok = new SoftwareObjectKey();
sok.setUID(uid);

// Get the instance of RegistryService
RegistryService regserv = (RegistryService)arg0.getServices().getService(RegistryService.NAME);

// Get the product's instance in the VPD
int productInstance = regserv.getNewestInstance(sok);
logService.writeToOutput("The instance of the product with a UID of " + uid + " is: " + productInstance);

if (productInstance >= 0)
{
// Set install dir to be the name of the product plus the install dir.

}
}
catch(com.installshield.wizard.service.ServiceException e)
{
}

drostowsky
01-24-2006, 04:56 PM
OK, I found that C:\Program Files\Common Files\InstallShield\Universal\common\Gen1\_vpddb\vpd.script gets updated with some DB insert statements containing my UUID. It does this instead of c:\windows\vpd.properties, but Im still not understanding why RegistryServices is still giving me -1 for product instances.

drostowsky
01-25-2006, 01:17 PM
I finally hacked my way around all this and figured out if I used another uuid instead of the product's uuid, like my main components uid, then the registryservice can find the instance. Is it a bug or by design that the products uuid cant be found?

Rob Lintern
02-06-2006, 01:41 PM
I too am having problems finding the product uuid using the resolveString("$P($P(beanId).key.UID)") technique.

Unfortunately getting the uuid of one of the product components is not adequate for me since it returns a different uuid than the product uuid.

After some experimentation, I've come up with the following code to get the product uuid. I have no idea if this a "good" way to do it but it seems to return the correct value.

public static String getProductUUID (ISContext context) {
String uuid = null;
try
{
ProductService productService = (ProductService)context.getService(ProductService.NAME);
ProductTree tree = productService.getSoftwareObjectTree(ProductService.DEFAULT_PRODUCT_SOURCE, new String [] {"key"});
ProductBean productBean = tree.getRoot();
if (productBean instanceof GenericSoftwareObject) {
SoftwareObjectKey key = ((GenericSoftwareObject)productBean).getKey();
uuid = key.getUID();
}
}
catch (ServiceException e)
{
e.printStackTrace();
}
return uuid;
}

Bruce Gardner
02-17-2006, 07:32 PM
I just posted a message about this as well:

http://community.installshield.com/showthread.php?t=156638

It looks like others are running into this in the group.

-Bruce

pjbeatty
02-27-2006, 12:34 PM
It appears to me that regservice.getNewestInstance(sok) is using both uid and version. I found that if I set the version
SoftwareObjectKey sok = new SoftwareObjectKey();
sok.setUID(uid);
SoftwareVersion softwareVersion = new SoftwareVersion();
softwareVersion.setMajor("1");
softwareVersion.setMinor("0");
softwareVersion.setUpdate("0");
softwareVersion.setMaintenance("0");
sok.setVersion(softwareVersion);

as well as uid, then regservice.getNewestInstance(sok) worked.