X
xJoey.t
I'm fairly new to msi and am trying to figure out how to change the
MinVersion and MaxVersions in the Upgrade Table using VBScript. I have
found a few examples but none of them seem to work. I would be using
the InstallShield Automation object but it has a bug when you try to
access an Upgrade table that has multiple entries. I found a Perl
script on the Installshield website and tried to convert it to VBS but
it's failing. This is the Perl I'm converting:
#!perl -w
use WIN32::OLE;
my $productVersion = "1.10.0015";
my $ismfile = "C:\\MyApp\\MyApp.ism";
#Need to open the project file in binary format for Windows Installer
to recognize it as a database.
$m_ISWiProject = Win32::OLE->CreateObject("SAAuto1050.ISWiProject") or
print "Cannot start ISIDE.\n";
$m_ISWiProject->OpenProject($ismfile);
$m_ISWiProject->{'UseXMLProjectFormat'} = 0;
$m_ISWiProject->SaveProject();
$m_ISWiProject->CloseProject();
#Using Windows Installer API to update the upgrade table
my $m_WIObject =
Win32::OLE->CreateObject("WindowsInstaller.Installer") or print
"Cannot create Windows installer object.\n";
# Open database in transacted mode
my $db = $m_WIObject->Opendatabase($ismfile,1);
my $newproducts_SQLstring=" SELECT * FROM Upgrade WHERE
ActionProperty='NEWPRODUCTS' ";
my $newView = $db->OpenView($newproducts_SQLstring);
$newView->Execute;
# Fetch the one and only record containing NEWPRODUCTS
$newRecord = $newView->Fetch;
#VersionMin is the 2nd field in the StringData property string. If you
would like to update VersionMax: that is the 3rd field in the
StringData property string.
#Set VersionMin to current ProductVersion
if (defined $newRecord){
$newRecord->SetProperty('StringData',2,$productVersion);
#Modify the view in mode 4 (MSIMODIFY_REPLACE).
#This mode is required because you need to update primary keys in the
table
$newView->Modify(4,$newRecord);
}
$newView->Close;
$db->Commit;
Don´t bother trying to use any fancy UPDATE sql statements with the
Upgrade table, it won´t work (VersionMin and VersionMax being primary
keys...).
When I run this it fails at the line:
$newRecord->SetProperty('StringData',2,$productVersion);
It appears that SetProperty is not a valid method here!
I hope someone can help, this is making me crazy!!
MinVersion and MaxVersions in the Upgrade Table using VBScript. I have
found a few examples but none of them seem to work. I would be using
the InstallShield Automation object but it has a bug when you try to
access an Upgrade table that has multiple entries. I found a Perl
script on the Installshield website and tried to convert it to VBS but
it's failing. This is the Perl I'm converting:
#!perl -w
use WIN32::OLE;
my $productVersion = "1.10.0015";
my $ismfile = "C:\\MyApp\\MyApp.ism";
#Need to open the project file in binary format for Windows Installer
to recognize it as a database.
$m_ISWiProject = Win32::OLE->CreateObject("SAAuto1050.ISWiProject") or
print "Cannot start ISIDE.\n";
$m_ISWiProject->OpenProject($ismfile);
$m_ISWiProject->{'UseXMLProjectFormat'} = 0;
$m_ISWiProject->SaveProject();
$m_ISWiProject->CloseProject();
#Using Windows Installer API to update the upgrade table
my $m_WIObject =
Win32::OLE->CreateObject("WindowsInstaller.Installer") or print
"Cannot create Windows installer object.\n";
# Open database in transacted mode
my $db = $m_WIObject->Opendatabase($ismfile,1);
my $newproducts_SQLstring=" SELECT * FROM Upgrade WHERE
ActionProperty='NEWPRODUCTS' ";
my $newView = $db->OpenView($newproducts_SQLstring);
$newView->Execute;
# Fetch the one and only record containing NEWPRODUCTS
$newRecord = $newView->Fetch;
#VersionMin is the 2nd field in the StringData property string. If you
would like to update VersionMax: that is the 3rd field in the
StringData property string.
#Set VersionMin to current ProductVersion
if (defined $newRecord){
$newRecord->SetProperty('StringData',2,$productVersion);
#Modify the view in mode 4 (MSIMODIFY_REPLACE).
#This mode is required because you need to update primary keys in the
table
$newView->Modify(4,$newRecord);
}
$newView->Close;
$db->Commit;
Don´t bother trying to use any fancy UPDATE sql statements with the
Upgrade table, it won´t work (VersionMin and VersionMax being primary
keys...).
When I run this it fails at the line:
$newRecord->SetProperty('StringData',2,$productVersion);
It appears that SetProperty is not a valid method here!
I hope someone can help, this is making me crazy!!