cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

Automation Interface -> ISWiPathVariables

I am trying to update a path variable in the ISM. I am using Perl to create the ISWiPathVariables object however, I am doing something wrong in that I cannot find a method to actually update a path variable - at least one that works.


$isProject = Win32::OLE->CreateObject ('ISWiAuto15.ISWiProject', \&OleQuit);
$isPathVariables = Win32::OLE->CreateObject('ISWiAuto15.ISWiPathVariables', \&OleQuit);

$isProject->OpenProject ($path);
$isPathVariables = $isProject->ISWiPathVariables;
my $pathVar = "PATH_TO_GOLD";
$isProject->AddPathVariable($pathVar);
$isProject->ISWiPathVariable ($pathVar, $pathToGold, $testVal, epvtCustom);


Note that $isProject->ISWiPathVariable does not work. The method is not found. However, if I try $isPathVariables->ISWiPathVariable it finds the method but I am told that I have an incorrect number of parameters.

The help documentation indicates that this should work with the project object. However, there are no examples in help for this so I am sort of fishing on my own 🙂

Can anyone help me better understand what I need to do to update a path variable? Thanks.
Labels (1)
0 Kudos
(6) Replies
Jesper_Eskilson
Level 3

I'm not sure what
The ISWiPathVariables (note the trailing "s") is a collection in the ISWiProject object, not a method. The path variable object is returned from the AddPathVariable method. I have a similar piece of code (but in Ruby):

@project = WIN32OLE.new(...)
@project.OpenProject(...)
...
variable = @project.AddPathVariable("VARNAME")
variable.Value = "..."


If you want to retrieve an existing path variable and update it's value, you should probably be doing something like


@project.ISWiPathVariables.each do |var|
if var.Name = "VARNAME"
var.Value = "new value"
end
end


I assume that you can express this similarly in Perl.
0 Kudos
DLee65
Level 13

I got the perl syntax figured out. My problem was in how to use perl to 'put' and 'get' values.

Below is my implementation in case anyone is interested:
[code]
##############################################################################
# @name SetPathVariable
#
# @brief Sets the path variable, if not found it creates a new one
#
# @arg1 ISM Project Object
# @arg2 item name
# @arg3 item value
# @returns 1 path variable is updated, 0 failed
#
# @author Dan Lee
#
# @version 1.0
##############################################################################
sub SetPathVariable ($$$)
{
#assign arg to variables - perl will throw exception if not enough args
my ($project, $itemName, $itemValue) = @_;
my $isPathVariables = "";

#backup warning level
my $warnlevel = $^W;

#Disable breaking on errors
$^W = 0;
if (not defined ($project))
{
die "SetPathVariable project not defined";
}

#fetch path variable collection
$isPathVariables = $project->ISWiPathVariables;
if (not defined ($isPathVariables))
{
die "SetPathVariables failed to get PathVariables collection";
}

#fetch single `record` by name
my $var = $isPathVariables->Item($itemName);
if (not defined ($var))
{
#if name is not found then create new name
$project->AddPathVariable($itemName);
$var = $isPathVariables->Item($itemName);
}

#Assign value to current `record`
$var->{Value}=$itemValue;
$^W = $warnlevel;
if ($itemValue ne $var->Value)
{
return 0;
}

return 1;
}
sub main()
{
die ("Usage: $0 $1 $2 \n") if @ARGV != 3;

my $retVal = 0;
my $projectFile = $ARGV[0];
my $pathToCurrent = $ARGV[1];
my $pathToGold = $ARGV[2];

Win32::OLE->Initialize (Win32::OLE::COINIT_MULTITHREADED);
#NOTE: ISQuit is a subroutine that calls CloseProject()
#sub ISQuit {my $object = shift; $object->CloseProject();}
$isProject = Win32::OLE->CreateObject ('ISWiAuto15.ISWiProject', \&ISQuit);
$isProject->OpenProject ($path);

$retVal = SetPathVariable($isProject, "PATH_TO_GOLD", $pathToGold);
if ($retVal == 0)
{
$isProject->CloseProject ();
die "Failed to set path variable for \"PATH_TO_GOLD\" to $pathToGold.";
}

$retVal = SetPathVariable($isProject, "PATH_TO_CURRENT", $pathToCurrent);
if ($retVal == 0)
{
$isProject->CloseProject ();
die "Failed to set path variable for \"PATH_TO_CURRENT\" to $pathToCurrent.";
}

$isProject->SaveProject ();
$isProject->CloseProject();

$^W = $warnLevel;


}
&main();
[/code]
0 Kudos
srivatsahg
Level 3

Hi D.Lee

Do you have a similar implementation for VB Script ?
I receive a similar error whenever i decide to change the value of a variable

Cheers
Srivatsa
0 Kudos
DLee65
Level 13

srivatsahg wrote:
Hi D.Lee

Do you have a similar implementation for VB Script ?
I receive a similar error whenever i decide to change the value of a variable

Cheers
Srivatsa


Unfortunately not. I have not revisited this code for some time. 😄
0 Kudos
SMadden
Level 6

Hi,

here is a snippet I use to update a standard path variable in a vbscript build script. Please note the pluralization for ISWiPathVariables. This was trial and error since the documentation has uses the singular form which didn't work for me.

set oProject = CreateObject("ISWiAuto18.ISWiProject")
oProject.OpenProject "myproject.ism", True
set oPathVariables = oProject.ISWiPathVariables
...
oPathVariables("my variable name").Value = "my new value"


-Sandra
0 Kudos
saipro10
Level 3

Hi,

I am trying to create sample application using Installshield 2009 which should install application without Admin-Rights.For that
In General Information - Require Admin Privileges set to "NO".
ALLUSERS = "1","2"
OS = Windows 7 Professional
User = Standard User(Non-Admin)

After setting above setting, I still getting an error 1925 stating that I do not sufficient privleges.

How do I rectify this issue, please help me out

Thanks & Regards,
Sai
0 Kudos