Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
First of all you need to encode the exe:
use strict; use warnings; use MIME::Base64 qw(encode_base64); my $buf; open(FILE, "$ARGV[0]") or die "$!"; binmode FILE; while (read(FILE, $buf, 60*57)) { print encode_base64($buf); } close FILE;
so you can use it ( in this way:
c:\>perl myexe.exe > mybase64.txt
Now, you need the script ( that encapsulates and extracts this exe:
use strict; use warnings; use Win32::API; use MIME::Base64 qw(decode_base64); my $exe_name="myexe.exe"; my $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N') +; if(not defined $GetTempPath) { die "Can't import API GetTempPath: $!\n"; } my $lpBuffer = " " x 80; my $return = $GetTempPath->Call(80, $lpBuffer); my $TempPath = substr($lpBuffer, 0, $return); my $exe_full_path=$TempPath."\\".$exe_name; print $exe_full_path.$/; open (FILE , ">$exe_full_path") or die "$!"; binmode FILE; print FILE decode_base64($_) while (<DATA>); close FILE; system("$exe_full_path"); unlink $exe_full_path; __END__ TVqQAAMAAAQAAAAAAAAAAAAAA etc. (the content of mybase64.txt)
this works for me on Windows XP and perl2exe 7:
that produces an exe. If you run it you run the first exe incapsulated in.
If you add a line like this:
system("$exe_full_path -$ARGV[0]");
you can run the first encapsulated exe with additional parmeteres passed by command line (of the first second exe).

In reply to Re: Include data in compiled perl .exe by dree
in thread Include data in compiled perl .exe by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (6)
    As of 2021-04-20 17:47 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found