Page 1 of 1

Is it possible to change a game's .exe image based on variables within the game?

Posted: Fri Dec 28, 2018 4:40 am
by Offworlder
If so, how would I go about doing this?

To give an example, let's say the .exe image (i.e. the icon that's clicked to open the game) is the game's logo to start with. Then, when the player makes a specific choice while going through the game, the .exe image automatically changes to a picture of the MC's face.

If this can be done only after closing the game window, that would be fine, too! Automatic would be more ideal, but the ability to accomplish something even close to this is what's most important.

Any and all help is greatly appreciated!

EDIT: I'm also referring to and want to change the icon that shows on the dock/taskbar when the game is open.

Re: Is it possible to change a game's .exe image based on variables within the game?

Posted: Fri Dec 28, 2018 1:19 pm
by rames44
The icon you click to launch the game: No, I don’t think this is possible. That image is built into the exe - “compiled in” when you build your distribution. Modifying it requires a change to the physical executable. In theory, you could build a .lnk file that POINTED to your executable and which had a different icon, but I’ve never done that with Python. Google might be your friend there. But don’t forget that Windows isn’t the entire world - any techniques for that won’t work on MacOS or Linux.

The icon that shows up at the top left of the game window itself MIGHT be changeable since it comes from a different place, but this would probably require you to dig deep into the Ren’py Python to get hold of the required windowing objects.

Re: Is it possible to change a game's .exe image based on variables within the game?

Posted: Sat Dec 29, 2018 3:38 am
by Offworlder
Thank you responding! Unfortunately, I'm not quite advanced enough to understand how to accomplish your suggestions. x_x;;
The game I'm making is going to be a gift, so it's fine if it only works on Windows.

Re: Is it possible to change a game's .exe image based on variables within the game?

Posted: Sat Dec 29, 2018 3:46 am
by PyTom
What you could do - might work, might not, might trigger your anti-virus - would be to build the game with the second icon. Grab the .exe from the zip file, store it in the game directory. Then when the game runs, it could copy the exe file from one place to another. The exe file isn't game specific, so you can copy one game's exe into another and it will probably work.

Something like:

Code: Select all

python hide:
     data = renpy.file("new.exe").read()

     with open(os.path.join(config.basedir, "old.exe")) as f:
         f.write(data) 
You may then need to run commands to clear the windows icon cache.

Re: Is it possible to change a game's .exe image based on variables within the game?

Posted: Sat Dec 29, 2018 4:34 am
by Imperf3kt
PyTom wrote: Sat Dec 29, 2018 3:46 am

You may then need to run commands to clear the windows icon cache.
Which unfortunately, won't take effect until explorer.exe service has been shut down and restarted - something the user will definitely notice (it causes Windows to go completely blank for a second)

And if you do it incorrectly, you end up with this:
Image (This is my own PC, I'm too lazy to bother fixing it)