Question : start external windows program with embeded answer file.


I'd like to automate an install of a windows application with a single perl script
rather that a batch file AND a answer file

normally, from a batch file I'd automate an install like so:

start /wait j:\apps\acrobat\setup.exe /a /s /sms /f1j:\apps\acrobat\setup.iss

 -where setup.iss is an install Shield answer file in text format.

Is it possible to embed the contents of setup.iss into the perl script itself?

Here's my meagre minimum...

# install acrobat

use warnings;
use strict;

my $pkg = '\\\\server\\apps\acrobat5\\setup.exe /a /s /sms /f1$iss';

print "Running $pkg...";
0 == system $pkg
    or die "$pkg failed: ", ($? ? $? : $^E);
print "done.\n";

# embede the answer file sowhere here

exit 0;


below would be the contents of $iss, but I'm cluless on how to embed it, much less pass it as if it were an outside answer file.

[contents of Install Shield answer file: setup.iss]

[InstallShield Silent]
Version=v5.00.000
File=Response File
[File Transfer]
OverwriteReadOnly=NoToAll
[DlgOrder]
Dlg0=SdWelcome-0
Count=3
Dlg1=SdAskDestPath-0
Dlg2=MessageBox-0
[SdWelcome-0]
Result=1
[SdAskDestPath-0]
szDir=C:\Program Files\Adobe\Acrobat 5.0
Result=1
[Application]
Name=Reader
Version=5.0
Company=Adobe
Lang=0009
[MessageBox-0]
Result=1

Answer : start external windows program with embeded answer file.

Ahh, I see.  

If you were disappointed with Winstall LE 2000, give 2003 a try.  It has matured a bit.  There *is* a bit of a learning curve with the new interface (at least, there was for me).  

As for "multiple OS" issues:  Most packagers will let you specify file installation paths based on system variables (e.g. %SYSTEMROOT%, %USERPROFILE%), which should help a bit.  You may have to dig around to *get* to the exact file paths, of course.
If not, some (most?) will allow you to script conditional install sections (e.g.  if c:\documents and settings exists, run section "Install2k", else run "InstallNT"    or   if OSisNT (NT,2k,xp,2k3) run "InstallNT" else run "Install9x"    or   if DLLVersion of c:\winnt\system32\crypt32.dll is "5.131.2195.6661" or higher, don't install the packaged version)


As for uninstalling a homebrew MSI, you should be able to signify certain components as 'Shared' and thusly "not removed on uninstall".
If you perfer a more functional approach (vs the OO-style of most MSI editors), try the SMS Installer/Packager.  I use the simple mode to pull diffs of installs, then use the expert mode to fine tune the script (remove extraneous files, add files the installer missed, etc).


As for SendKeys:    Did you know that the SendKeys functionality exists in Perl?  Of not, check out: http://search.cpan.org/~erngui/Win32-GuiTest-1.3/GuiTest.pm


As for difference repackages:  Yes, these are *best* suited for homogenous environments.  However, with Shared Files and condition installs, you can make most repackages work with any modern Windows OS (95 or newer).    It all depends on whether it would be faster to run around and perform manual installs on every computer, or take the time to build a robust package.  


Also, a tip for packaging:  I have found that repackagers that require you to specify a setup application to run may miss parts of installs that are performed by multiple processes/applications (i.e. one application decompresses setup data, then passes execution off to one fo the files it just decompressed)  I have had anecdotally better luck with using Sync.exe from SysInternals as the app to be repackaged.  Sync makes no changes to files, and is thusly a benign host for such tasks.   YMMV, of course.


Anyways, I wish you luck in your endeavour.  I have been where you are now :)    (And I, too, used quite a bit of Perl and PsExec to make the square peg fit the round hole)
Random Solutions  
 
programming4us programming4us