Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Icon for pp on Strawberry

by aplonis (Pilgrim)
on Jun 13, 2017 at 15:38 UTC ( #1192706=perlquestion: print w/replies, xml ) Need Help??

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

Since the demise of the --icon option inside of pp, I had for some time now been doing the icon-swap with Win32::Exe instead. But now I am finding that that is no longer reliable. For some scripts it works just fine. For others, though, it works just by half. On those where it half-works, the *.exe will actually run, but only after issuing errors at top of console. Those errors seem all to be complaints about the archive itself. And sure enough, if I change the extension from *.exe to *.zip after a Win32::Exe icon-swap, then WinZIP says the archive is corrupt. Then, after I change back, the *.exe once again half-works with errors just as before. It does what I want, but only after a slew of archive-complaints.

format error: bad signature: 0xdd58f7da at offset 5068572 in file C:\Users\gstarl\Desktop\foo.exe at -e line 614.

A whole bunch like that. All different HEX, at different locations, all at line 614. And WinZIP won't open it after the change.

If it were only just for myself, then I could be living with that. But if it were just for myself, I'd leave it as *.pl and not bother creating an *.exe. That is something I only ever do for other people. And the errors lists, however seemingly harmless, will cause alarm in those folks.

So... I was wondering, might there perhaps be away to trick pp itself into using always a different *.ico file, instead of the Camel?

The reason I want that, (aside from vanity) is to flag those *.exe files I've written apart from any that have been downloaded. Since running one on Windows always gives the pop-up warning "May harm your computer," I've gotten folks here to trust the in-house ones which have a non-camel icon.

I've searched my whole PC for every instance of the camel, and replaced it temporarily, trying out pp to see if it got carried through. But not even replacing the pp.ico camel inside of Strawberry itself had no effect. Camels come out the other end, no matter what. I like the camel just fine. I do. But I need to enforce some distinction in-house for scripts that I've written, if only because now folks are used to it.

Since no longer I can change the icon after making the *.exe, is there any way to fool pp into using a different *.ico originally?

Replies are listed 'Best First'.
Re: Icon for pp on Strawberry
by salva (Abbot) on Jun 13, 2017 at 15:48 UTC
    I do that using Resource Hacker which is scriptable using its own little language.

      Okay, tried "Resource Hacker" but with the same exact result. Resultant *.exe works. But just like after icon-swapping with Win32::Exe it gives same kinds of archive-complaint errors when it is run.

Re: Icon for pp on Strawberry
by pryrt (Prior) on Jun 13, 2017 at 17:57 UTC

      Thanks pyrt for link to that node.

      You might have better luck getting the makefile approach in that link to work. For my use case I manually replace the pp.ico file with my own version when building PAR::Packer. It works well enough when there is only have one icon file to use across executables.

      Some explicit commands to build using cpanm are:

      :: Install the dependencies first cpanm --installdeps PAR::Packer :: Now manually install PAR::Packer cpanm --look PAR::Packer rename .\myldr\winres\pp.ico pp.ico.bak copy \path\to\my\icon.ico .\myldr\winres\pp.ico perl Makefile.PL :: if gmake is not available then use dmake instead gmake gmake test gmake install

      If you want to use a different icon file for different exe files then you could probably have multiple PAR::Packer installations using a local lib approach. Others would be better placed to give examples of that, though.

Re: Icon for pp on Strawberry
by aplonis (Pilgrim) on Jun 26, 2017 at 21:48 UTC

    SOLVED: Here's what works. It's not even hard.

    If pp is already installed, then remove it with cpanm --uninstall pp

    Find the directory C:\Strawberry\cpan\build\PAR-Packer-1.037-0 (or equivalent) and delete it completely.

    Re-get PP from plain Jane, regular CPAN like so get pp but do NOT make or anything else.

    Find the directory C:\Strawberry\cpan\build\PAR-Packer-1.037-0\myldr\winres (or equivalent) which you had just now got

    Delete from that dir the file pp.ico and replace it with your own *.ico file naming it as the new pp.ico

    Now open a CLI (aka DOS) window into the path C:\Strawberry\cpan\build\PAR-Packer-1.037-0 (or equivalent) and do...

    perl Makefile.PL

    Then dmake Makefile

    Then dmake test

    Then dmake install

    And now you are done. Henceforth a call to pp will have your own *.ico already built in. Sorry, no changing back. Start over from scratch if you want to do that.

    And if for you, as it does for me, a call to pp in the regular way still dies with errors, next go hunting right here at PerlMonks for something called and use that instead. This is what I have had to do. A few hoops to jump through but at last now it works.

      Nice, a suggestion, cpanm is faster than cpan and you can replace your command prompt actions

      perl Makefile.PL dmake Makefile dmake test dmake install


      cpanm .

      This also has the advantage of cpanm dealing with prerequisites of pp, should they change.

      Update: "Re-get PP from plain Jane, regular CPAN like so get pp but do NOT make or anything else." - cpanm has a --look method: "Download and unpack the distribution and then open the directory with your shell". link to for completeness.

      Thanks! It worked for me!

      Just a little update:

      1. cpanm --uninstall pp didn't work. I used cpanm -U pp .

      2. I didn't re-get pp.

      3. Use gmake instead of dmake.

        Hi All Can anyone write down the exact (updated) instructions to doing this for someone not familiar with make,gmake,dmake.... Thanks
Re: Icon for pp on Strawberry
by soonix (Abbot) on Jun 18, 2017 at 12:02 UTC
    • Do you get the same error if you modify it via (which is merely a wrapper around Win32::Exe, but perhaps it uses the parameters different?
    • Win32::Exe or PAR::Packer might be corrupt. Perhaps try a reinstall?
    • Do you have different Perl versions on your computer? If yes, check which one you are using, if not, now could be a good time to start :-)

      Yes. Then also.

        To elaborate on my third bullet point "different versions": You could try out, either directly (using Strawberry's "portable" editions) or via berrybrew:
        • a 64bit Perl if your "normal" Perl is 32bit
        • a 32bit Perl if your "normal" Perl is 64bit
        • a Perl version that is older than your "normal" Perl
        • the newest available one
        Beware that all needed CPAN modules have to be installed on each Perl separately.
Re: Icon for pp on Strawberry
by aplonis (Pilgrim) on Jun 26, 2017 at 18:59 UTC

    Another strange thwart in Strawberry's PP.

    I got the idea to do cpanm --uninstall pp then replace the pp.ico in the path...

    C:\Strawberry\cpan\build\PAR-Packer-1.037-1\myldr\winres I could then rebuild PP with dmake

    But every single time when I delete pp.ico then copy in foo.ico and rename the latter as pp.ico on hitting return it changes itself back to the camel icon. At least as seen in the file browser. I drag it outside of the directory winres and onto the Desktop and it goes back to what I made. I put it back into winres and it's a camel again. I open it from inside of winres with GIMP and see the icon I made. I use any other image viewer and see the icon I made. But in the file browser, always it is a camel regardless. And any *.exe which I make even with a PP rebuilt using dmake still comes out with the camel showing. How is that even possible?

Re: Icon for pp on Strawberry
by Anonymous Monk on Oct 05, 2017 at 04:53 UTC
    Something seems fouled with the .ico data in any perl compiled .exe for windows. Using Resource Hacker on ANY other normal .exe, the .ico data can be seen and looks completely normal: 1 icon group defining all icons, and then all of the icons with multiple sizes. With a Strawberry PERL compiled .exe, there are 4 files in the icon group, but they point to only 2 sized icons. 16x16(256c) and 32x32(235c). However, it points to them twice, so of the 4 files that the icon group points to, it points to 2 16x16 icons and 2 32x32 icons. If I use any icon creation utility, and define the .ico to only carry 16x16(256c) and 32x32(256c), and use REsource Hacker to overwrite the perl .exe's icon data, Resource Hacker correctly puts only 2 icons into the icon groups. But the file size is still changes. I'm concluding that the perl .exe has 2 valid icons in it, but two faulty icons and due to their size, cannot be modified by any 3rd party icon modification tools.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1192706]
Approved by Eily
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2019-10-22 12:20 GMT
Find Nodes?
    Voting Booth?