Set a Windows exe icon from Linux (without Wine ?) - linux

I'm trying to set a Windows executable icon with a Bash script in Linux, but I can't find anything relevant.
I have found this tool www.nongnu.org/icoutils, but it seems to me that you can only extract .ico file from the executable (then convert it into png), or do the opposite: it takes pngs and it creates an .ico BUT it can't write the new ico into the executable.
Am I right or wrong ? What should I do ?
By the way, I've found this thread and this one, but they do not fully answer the question...
Thanks !

One way would be to use Resource Hacker with wine.
Therefore,
install wine
download Resource Hacker
install Resource Hacker with wine (or wine32 if you are on 64bit):
$ wine32 /path/to/reshack_setup.exe
change icon:
$ wine32 .wine/drive_c/Program\ Files/Resource\ Hacker/ResHacker.exe -addoverwrite "oldexe.exe,new.exe,new.ico,ICONGROUP,MAINICON,0"
This worked for me on a few .exe files. It also failed on one, i don't know why.
Hope this helps!

Related

How do I get a portable installation of the Rust programming language?

I've been trying to get a windows installation on a flash drive for a while now.
Since this question comes up first in the search engine when I searching for installing Rust on a pen drive. I'll answer it.
Installing on pen drive makes sense on Windows, if you want to carry the installation with you.
Download rustup-init.exe from the official Rust page (you probably want the 64 bit one nowadays).
set RUSTUP_HOME and CARGO_HOME environment variables to point to a location on your pen drive.
When you start it will echo back these environment variables. To let you verify it.
When asked tell it to customize install.
I have portable MinGW on my pen drive so I have chosen x86_64-pc-windows-gnu as the host triplet to install.
Tell it to not to alter your PATH, instead have a BAT script that you can start to set these vars for the shell.
I have a BAT script on the pen drive to ensure the PATHs are right despite what drive letter gets assigned, such as this:
set DRIVE=%CD:~0,2%
set MINGW_PATH=%DRIVE%\!\Mingw64\mingw64\bin
set GIT_PATH=%DRIVE%\!\PortableGit\cmd
set VSCODE_PATH=%DRIVE%\!\VSCode
set RUSTUP_HOME=%DRIVE%\!\Rust\rust
set CARGO_HOME=%DRIVE%\!\Rust\cargo
set RUST_PATH=%CARGO_HOME%\bin
And when you plug in the pen drive to a different computer, then after the install run this bat to have the paths.
Notice: note that this way can not use in ExFAT filesystem. Please see this issues
Something like https://www.codejam.info/2015/03/portable-rust-installation.html might work? Possibly with putting the profile script on the drive to be run after inserting? Also, is this for Linux, Windows or something else?
First, get the binaries according to your system, and the Rust version
you want. For me (nightly 64-bit Linux binaries) and extract the
archive (I like to put it in ~/opt):
wget https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz
mv rust-nightly-x86_64-unknown-linux-gnu rust
Then, just export the appropriate environment variables (do this from
your ~/.profile or equivalent to have it set up automatically). No
need to install anything globally!
export LD_LIBRARY_PATH=~/opt/rust/rustc/lib:$LD_LIBRARY_PATH
export PATH=~/opt/rust/rustc/bin:~/opt/rust/cargo/bin:$PATH

x64 Portable executable not working

I created an exact replica of this file in a hex editor: https://i.imgur.com/LIImg.jpg
The problem is, the .exe file I made from it doesn't work, it says it's an invalid Win32 application when trying to run it. Is there something flawed in it? I've checked and double checked my file...
I'm not sure where I can host an exe file but I can email it if someone else wants to check it.
I should also mention I'm running Windows 7 64-bit.
The PE binary file from that illustration is already available here from the author, Ange Albertini. I have tested it both on Windows 7 and Windows 8/8.1, and it runs just fine, so you can use it for comparison with your binary.
In case anyone was wondering, the difference between the image and the executable is that there has to be 0's at the end of the file to match the section size. It doesn't work without that.

How to change windows exe file's icon in linux without wine?

I know I can use ResHacker to change a resource from windows and I know I can use ResourceUpdate function to do the same problematically (again in windows). My problem is that I have to update the icon of a windows exe file in linux, without using wine.
(the reason for not using wine is that this process should run on an automation server that change the files and sign them).
I don't know even where to start from.
You can change a files metadata like this:
gvfs-set-attribute '/path/to/file' -t stringv metadata::custom-icon "/path/to/image.png"
There's a program called windres that should suit your needs
Whoops, that's just a resource compiler, sorry.
However there is pefile a python module for working with PE executables, perhaps you could write a script with it that does what you want

Custom Cygwin distribution?

Is there anyway to create a Cygwin distribution that has customized packages? In other words, can I just zip up my cygwin folder and unzip it to another computer for it to work straight away?
Or are there registry\path configurations that would only bet set correctly by running the setup.exe?
I'd browse the Cygwin Archives to answer this question.
(added after Bei337's first comment)
I believe the Cygwin FAQ answers your question.
You can archive (e.g. zip, 7-zip etc.) the contents of the cygwin directory and it'll work on another computer after unarchiving if you make sure that cygwin.bat contains the correct paths.

Tutorial/Guide to create a classic, small Linux application in a package (Debian)

I've made a small script in my machine, and an alias in .bashrc that calls it. It's a bash script with 3 lines, but it can grow.
Now, some people in my team found it useful, and want to use it.
Instead of saying "copy this alias, do this, do that, install that lib" I was thinking about creating a simple package to be a little more professional. Fact is, I've never done something like this before. And the problem to me is not creating a package, is trying to decide what usually do you put in a package.
Suppose I want to take my script, and create myapplication. I want to create a .deb file that my team would install and:
Have a /usr/bin/myapplication or /usr/sbin/myapplication (what's the difference between them?), so they would just call myapplication at their terminal and it would work;
Have a man page; (Where are usually located man pages in a debian system?);
Have a possibility to read a .myapplicationrc in home folder with some configurations;
Have an entry for shortcuts in a gnome installation (is it possible to have an universal shortcut "format" that's is available to KDE and Gnome as well?);
Install dependencies.
I'm new to all that stuff. I usually code simple scripts and create an alias in my bashrc. I've never done a package before. Which guides do you know of that can help me accomplish what I thinking of above?
Here is a place to start, though I welcome a more succinct answer.
I couldn't find a complete guide. I think the best thing to do is download a package that does exactly what I'm thinking of and do some reading, like taskwarrior.

Resources