in reply to Perl script to change product code and product version in installshiled project (.ism) file?

Use UUIDGEN to get those random unique guids on Win boxes.

sub newguid { local($id)=`uuidgen.exe` || die "$0: Cannot run UUIDGEN.EXE\n"; chomp($id); return $id; }
  • Comment on Re: Perl script to change product code and product version in installshiled project (.ism) file?
  • Download Code

Replies are listed 'Best First'.
Re^2: Perl script to change product code and product version in installshiled project (.ism) file?
by GrandFather (Saint) on Sep 23, 2009 at 22:57 UTC

    There are a pile of modules in CPAN for GUID generation (Win32::Guidgen, Win32API::GUID, Data::UUID, ...), although for product codes it's often useful to generate a GUID given the product name (and possibly version number). In Win32::MSI::HighLevel I do that using:

    use Digest::MD5 qw(md5_hex); sub genGUID { my $seed = shift; my $md5 = uc md5_hex ($seed); my @octets = $md5 =~ /(.{2})/g; substr $octets[6], 0, 1, '4'; # GUID Version 4 substr $octets[8], 0, 1, '8'; # draft-leach-uuids-guids-01.txt GUI +D variant my $GUID = "{@octets[0..3]-@octets[4..5]-@octets[6..7]-@octets[8.. +9]-@octets[10..15]}"; $GUID =~ s/ //g; return $GUID; }

    True laziness is hard work
      Hi I have written following code to read the data from .ism file. Similar way I will write a code to write data in .ism file but my code is failing with an error saying "Can't call method "OpenProject" on an undefined value at C:\Test\Update_ism.pl line 15." Following is the code. Can you please suggest how do I get rid of this.
      use Win32::Guidgen; use Win32::OLE; my $guid = Win32::Guidgen::generate(); #Generate GUID for Product code +. # instantiate the Developer Automation interface $dev = Win32::OLE->new("ISWiAutomation.ISWiProject"); # open a project file. $dev->OpenProject("C:\\InstallShield 2010 Projects\\Test.ism") or die +"Can not open project file:$!"; print "ProductName: " , $dev->ProductName, "\n", "ProductVersion: ", $dev->ProductVersion, "\n"; # close the project $dev->CloseProject( );