premal has asked for the wisdom of the Perl Monks concerning the following question:

Hi I want to write a perl script which will randomly generate a Product code, increment a version number of a product and update the same in an Installshield project file (.ism). The product code will be like {C5FE228F-1FC9-495F-8DC5-C072862D305D}. I am new to perl can you please help?
  • Comment on Perl script to change product code and product version in installshiled project (.ism) file?

Replies are listed 'Best First'.
Re: Perl script to change product code and product version in installshiled project (.ism) file?
by GrandFather (Saint) on Sep 23, 2009 at 11:29 UTC
Re: Perl script to change product code and product version in installshiled project (.ism) file?
by vitoco (Hermit) on Sep 23, 2009 at 13:48 UTC

    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; }

      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( );