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

has anybody used PerlMSI which comes with Perl Dev Kit. In ScriptGenerator.pl I add following code to create a shortcut.
$installer->SetShortcut('ProgramMenuFolder/Digest/f06Digest', 'Digest/Digest.exe');
It creates the shortcut but when I run Digest.exe file, the exe file starts but does not continue. I had a look at the properties of the shortcut and realised that "Start In" property was empty. When I fill "Start In" entry with correct path the exe file starts. So My question is how can I set the "Start In" property of the shortcut from PerlMSI. I don't expect a reply. I know there aren't many people out there who use PerlMSI. But I just wanted to try, because I could not get any help from www.activestate.com.

Replies are listed 'Best First'.
Re: Active Perl Dev Kit
by tachyon (Chancellor) on Nov 10, 2002 at 13:59 UTC

    If you check out the source of MSI::Installer.pm's SetShortcut() method and you will see:

    $self->{msi_db}->AddData(Shortcut => [ {'Shortcut' => StrToUKey($target_file +), 'Directory_' => $dir_key, 'Name' => $shortcut_name, 'Component_' => $component, 'Target' => $Feature, 'Arguments' => $argument_str, 'Description' => 'Description', 'Hotkey' => undef, 'Icon_' => undef, 'IconIndex' => undef, 'ShowCmd' => undef, 'WkDir' => undef, }],

    If you have a look here you will see the property names associated with shortcuts objects in VBS. You can see the WorkingDirectory property. I strongly suspect that 'WkDir' in the above code corresponds to this. So just hack the Installer.pm source to take a 4th arg and use it to set 'WkDir'. With a bit of luck it should work. For reference here is a VBS example of creating shortcuts which shows you the object property names. In a worst case you could always run something like this to generate the required shortcut.

    ' Get a Shell object Dim WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") ' Create a shortcut object Dim MyShortcut Set MyShortcut = WSHShell.CreateShortcut("C:\Temp\Shortcut.lnk") ' Set shortcut object properties and save it MyShortcut.TargetPath = "\\server\xyz\foo.exe" MyShortcut.WorkingDirectory = "\\server\xyz" MyShortcut.WindowStyle = 4 MyShortcut.Save

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Active Perl Dev Kit
by Jenda (Abbot) on Nov 10, 2002 at 16:49 UTC
      Thanks to everbody who responded. I have finally managed to get it working. My application was under Digest folder. Under Digest there were images folder and when I run digest.exe from the shortcut it could not start because it could not locate the images.
      Digest/digest.exe Digest/images/digest.ico Digest/images/digest_1.gif Digest/images/digest_2.gif
      I have put following code in ScriptGenerator.pl and it worked (I did not need to specify where the images were). This method of creating shortcut tells windows where to "Start In" :
      $installer->AddData(Shortcut => [ { Shortcut => "DIGEST_DIGEST.EXE", Directory_ => "PROGRAMMENUFOLDER_DIGEST", Name => "Digest|Digest", Component_ => "Digest_Digest.exe", Target => "TOP_FEATURE", Arguments => undef, Description => 'digest.exe', Hotkey => undef, Icon_ => undef, IconIndex => undef, ShowCmd => undef, WkDir => "DIGEST", }, ], );