Loading
can't set keypath via IswiAuto14.ISWiProject?
Hi all, I'm trying to use the developer automation interface via Perl and everything seems to work great other than setting a key file in a component. When I use the SetProperty() function to change the keypath it seems to have no effect.

 

I have a test file called InstallShieldProjectForUnitTests1.ism that contains one component "testComponent1" which contains one file with the key value "testfile2" (& filename testFile2) and I want to make this file the component's key file.

 

Here is the output from my test program:

 

>>>

 

Unquoted string "undefined" may clash with future reserved word at test3.pl line

 

10.

 

Unquoted string "false" may clash with future reserved word at test3.pl line 28.

 

created iswiPrjObj

 

project opened successfully

 

keypath of component testComponent1 is

 

intial key for component testComponent1 is

 

setting key in component testComponent1 to testfile2...

 

setting file testfile2 as key in component testComponent1

 

keypath of component testComponent1 is

 

key for component testComponent1 is now

 

saving project, return value: 0...

 

entering InstallShieldProject::OLE destructor

 

>>>

 

and here is my test program:

 

>>>

 

!/usr/bin/perl -w

 

use Win32::OLE;

 

my $global_ISPrjFilePath = 'InstallShieldProjectForUnitTests1.ism';

 

my $global_ISPrjObjPrefix = "IswiAuto14";

 

my $oleObj = "$global_ISPrjObjPrefix.ISWiProject";

 

my $global_iswiPrjObj = undefined;

 

$global_iswiPrjObj = Win32::OLE->new($oleObj,

 

sub

 

{

 

print "entering InstallShieldProject::OLE destructor\n";

 

$global_iswiPrjObj->CloseProject();

 

} );

 

if($global_iswiPrjObj)

 

{

 

print "created iswiPrjObj\n";

 

} else {

 

die "unable to create iswiPrjObj\n";

 

}if-else

 

opening for read-write

 

my $OpenPrjRetVal = $global_iswiPrjObj->OpenProject($global_ISPrjFilePath, false);

 

if(0 == $OpenPrjRetVal)

 

{

 

print "project opened successfully\n";

 

} else {

 

print "OpenProject() returned $OpenPrjRetVal\n";

 

}if-else

 

my $componentOfInterest = "testComponent1";

 

my $keyOfInterest = "testfile2";

 

print "intial key for component $componentOfInterest is " . getComponentKey($componentOfInterest) . "\n";

 

print "setting key in component $componentOfInterest to $keyOfInterest" . "...\n";

 

setKeyInComponent($keyOfInterest, $componentOfInterest);

 

print "key for component $componentOfInterest is now " . getComponentKey($componentOfInterest) . "\n";

 

print "saving project, return value: " . $global_iswiPrjObj->SaveProject() . "...\n";

 

 

sub setKeyInComponent

 

{

 

my $Components = $global_iswiPrjObj->ISWiComponents;

 

my $Component = $Components->{"$_[1]"};

 

print "setting file $_[0] as key in component $_[1]\n";

 

$Component->SetProperty(ISWiComponent.KeyPathType, kptFile);

 

$Component->SetProperty(ISWiComponent.KeyPath, $_[0]);

 

}sub setKeyInComponent

 

 

 

sub getComponentKey

 

{

 

my $Components = $global_iswiPrjObj->ISWiComponents;

 

my $Component = $Components->{"$_[0]"};

 

my $ComponentKey = $Component->KeyPath;

 

print "keypath of component $_[0] is $ComponentKey\n";

 

return $ComponentKey;

 

}sub getComponentKey

 

>>>

 

Does anyone have any ideas? Thanks so much in advance!

  • Community Manager (Flexera Software)

    It might be the SetProperty syntax you're using; as a quick test, this test seems to work:

     

    use Win32::OLE;

     

    my $is2008 = Win32::OLE->new("ISWiAuto14.ISWiProject");

     

    open project read-write

     

    $is2008->OpenProject("PerlAutoTest.ism", "false");

     

    get component "c1"

     

    my $comp = $is2008->ISWiComponents("c1");

     

    set its key file (type 2) to "c1.txt"

     

    $comp->SetProperty(KeyPathType, 2);

     

    $comp->SetProperty(KeyPath, "c1.txt");

     

    save and close the project

     

    $is2008->SaveProject( );

     

    $is2008->CloseProject( );

     

    clean up

     

    undef $is2008;
    Expand Post
  • Hi Robert, you're the man!

     

    It works - it seems what needs to be done is not to prefix the property with ISWiComponent. The key is to do something like this:

     

    $Component->SetProperty(KeyPathType, kptFile);

     

    $Component->SetProperty(KeyPath, $ComponentFileKey);

     

    ktpFile (instead of the value 2) seems to work fine.
    Expand Post
  • In my previous post I mentioned using "kptFile" instead of the value 2 seemed to work. Well apparently it may not (how did it work the other time? grrr) anyways for those reading this thread experiencing the same problem just use the value 2 as it seems to work and "kptFile" seems to be iffy.

Loading
can't set keypath via IswiAuto14.ISWiProject?