@echo off echo Searching Perl Interpreter ... if not exist c:\strawberry\perl\bin\perl.exe goto usesbp rem # no strawberry perl, perhaps ActiveState? if exist c:\perl\bin\perl.exe goto useap rem # nope, any other perl along the path? perl -e "print qq/Found Version $]\n/; exit 42" if errorlevel 43 goto noperl if errorlevel 42 goto haveperl :noperl echo No perl found, installing Strawberry Perl ... strawberry-perl-5.x.y.z.exe /command /line /parameters /for /silent /install :usesbp PATH=C:\strawberry\c\bin;c:\strawberry\perl\bin;%PATH% rem # ^-- PATH is not automatically updated after installation for THIS batch rem # paranoia: do we really have a working perl? perl -e "exit 42" if errorlevel 43 goto brokensbp if errorlevel 42 goto haveperl :brokensbp echo Perl installation failed! goto die :useap PATH=C:\perl\bin;%PATH% rem # paranoia: do we really have a working perl? perl -e "exit 42" if errorlevel 43 goto brokenap if errorlevel 42 goto haveperl :brokenap echo Existing Perl installation is broken! goto die :haveperl perl -S -x %0 if not errorlevel 1 goto end echo Installer script died unexpectedly! goto die #!perl use 5.010_000; # or any earlier version your app runs with # line 40 # ^-- replace with number of THIS line or the line numbers will not match the source use strict; use warnings; use FindBin; use Cwd; use Archive::Tar; use File::Path qw(mkpath); my $cwd=getcwd(); print "Installer invoked as $FindBin::Script (in directory $FindBin::Bin),\n", "current directory is $cwd,\n", "Perl is $^X.\n"; my $tar="$FindBin::Bin/myapp.tar.gz"; my $dest="C:/foo/bar"; -f($tar) or die "Could not find myapp.tar.gz in $FindBin::Bin"; -s _ or die "myapp.tar.gz is empty! Died"; # Maybe test for required modules, install missing ones using the CPAN classes, # perhaps from a compressed repository included in the installer. mkpath($dest); -d($dest) or die "Failed to create $dest"; chdir($dest) or die "Failed to chdir to $dest: $!"; Archive::Tar->extract_archive($tar,1) or die "Failed to unpack $tar: $Archive::Tar::error"; print "Finished installing the FooBar application\n"; exit 0; __END__ :die pause :end