Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Newb not sure how to call Installer Database


5 replies to this topic

oyeyoy

oyeyoy
  • Members
  • 2 posts

Posted 03 February 2005 - 00:29

Hi,

I'm using Visual Studio .NET, and I have the primary output of an installer class as a custom action. I just want to get the product version from the Installer Database, but I am unable to call the MsiGetActiveDatabase() from my Installer class- I get "The name 'MsiGetActiveDatabase' does not exist in the class or namespace 'SetupDialog.Installer1'" when I try to compile.

It seems like I'm missing a 'using' directive, but I don't which one.

I've also tried using a vb script as a custom action with this

Session.Property("ProductVersion")

but that too causes problems.

After running my msi file, I get the message box- "There is a problem with this Windows Installer. A script required for this install to complete could not be run...."

Any thoughts/suggestions are appreciated.

Stefan Platamone

mandy

mandy
  • Members
  • 121 posts

Posted 04 February 2005 - 14:49

Session.Property("ProductVersion") should be correct - assuming the session is available at the time. The custom action must be scheduled to run at the right time - most properties aren't available during deferred execution.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 04 February 2005 - 15:44

There's probably a syntax error in your VBScript. Can you post your script here?

oyeyoy

oyeyoy
  • Members
  • 2 posts

Posted 04 February 2005 - 23:09

Thanks for the responses- I appreciate them! This site is an incredible resource!

I started with this script, which I found on the web:

' open and execute the view
Set oView = Database.OpenView("SELECT `Value` FROM `Property` WHERE `Property`='ProductName'")
oView.Execute

' fetch the one and only ProductName record
Set oRecord = oView.Fetch

' display the string data from the fetched record
MsgBox "ProductName = " & oRecord.StringData(1)

' clean up
oView.Close

This still results in an error.

I no longer get an error when I run this:

MsgBox "ProductName = " & Session.Property("ProductName")

But, the Session.Property("ProductName") doesn't seem to evaluate to anything (even though the ProductName is set in the properties of the Setup project.) I just get a message box with "ProductName =". I tried adding a .toString(), but that resulted in an error. (I told you that I am a newbie.) Any tips/insights are helpful, especially anything about accomplishing this in an Installer.cs class would also be helpful. Even though I feel like I have done an exhaustive search on the net, I'm obviously missing something.

Thanks again for your time.

Stefan

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 February 2005 - 10:33

As far as I know Visual Studio Installer only build Deferred (or rollback or commit) custom actions, but no "immediate" custom actions. However immediate is the only type that has full access to the installer session, to read properties. You should add an immediate action to get the product name. For ths purpose you will have to post process your msi file with Orca or use a different tool other than Visual Studio. Windows Installer support in VS.NET is very limited.

mandy

mandy
  • Members
  • 121 posts

Posted 05 February 2005 - 21:11

Your script is correct. The most likely problem is that the session isn't available at the time your custom action runs.

When you use "Database.OpenView", that should be shorthand for "session.database.openview".