Change .exe name w/in delphi

Is there a way to specify the name of the exe that you want with the project source?  The only way I know how to do this now is rename the project.  Is there an easier way?
Who is Participating?
zwarteConnect With a Mentor Commented:
Correct me if I am wrong, but won't your version change everytime you do a build all, or run your program, so working with the inifile and the counter won't do you any good.
including it in the compiler directives won't help either 'cause you'd have to modify and rebuild your *.scr file every time.
using a batch file won't rename your file right unless you modify your batch file all the time.

My suggestion is to write a small application in delphi simply checking the directory with all your *.exe's and then looking for the last version. Add 1 to the version, and then rename and copy your exe from your working directory to your *.exe directory.

general structure would be:

{gets all the filenames from the dir where you keep your exe's}
{looks at all the filenames and extracts the highest version number}
{copies your exe from your working directory to the directory where you keep your *.exe's and modifies the name to bear a higher version number}


This program will allow you to make a new build of your exe whenever you like and you'll be sure that the exe has a higher version number (you might want to consider including a date or time in the name)

I could work out all the procedures, but I think you get the point ;-)

I dont really know of a way to do this other then the one you gave.  But there is no reason why you cant rename the exe file after you have compiled.  I do this all the time.

regsoftAuthor Commented:
Yes - I do that as well - I just thought there would be a way like when you compile a Screen Saver - you can add  {$E SCR}  to make the .exe (the extension)  be a .scr .  I assumed there may be a way to change the actual .exe filename.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

?Why do you need that?
regsoftAuthor Commented:
Each new release of my app - I like to put the version in the .exe name MFK4.0.0.exe
I can then have all the previous .exe named accordingly.  Right now after I compile, I re-name it.

Hi RegSoft,

Maybe a batch file?
Make a commandline compiler batchfile where you rename the resulting exe in the end?
Try reading a variable from a file.... for example use an INI file and each application you write just write it's title as the item unde category and then assign a value for that item.,.. the use the initializatio nto read that value in and change the name of the application...

for example...

Last Shareware=v1.2

then you read that value and your title would be as follows...

Last Shareware v1.2

and so on..

you use the initialization to set the aplication's name...

............the code goes here,,,,,
//the you do this,,,
  Application.ExeName := TheNameYouReadFromYourIniFile;

I've also seen Delphi exeperts (i think that's what they are called) that when you run the program they can change the version and all that in design time.... everytime you compile it changes the name.. you could try looking for them on DSP, Torry's pages, and so on... I don't exactly remember where I saw it, but if I find something I;ll let you know..

regsoftAuthor Commented:
I thought there was an easy way to it like {$E SCR}  (makes the .exe a .scr at compile time)

Thats what I was looking for.

Thanks anyways
>>>viktornet : Correct me if I'm wrong on this but I guess you have to change your ini everytime before you run or not? Think that isn't that much of a difference then changing the name of your exe.

>>>regsoft : When you introduce some intelligent counter object that's reading the inifile from viktor and updating the version counter with one, just like the build in the IDE, and writing that value in your inifile then I think this should work.
:O)Always happY.
yeah, the problem with this is that you should change the INI everytime... but at least you don't do it manually and have Delphi code to change it for you,,,,
Hmmmm....didn't see that post coming did some time traveling again.
Maybe I should change my machine time, but I get my posts not there in the void in time, even if regsoft won't use this, think we got a workable solution here.

Put some information and your exename in an inifile.
Read the version number when you build / compile / run.
Let a counter object change the version number.
Write the new name.
And read the new name into your executable.

Think this will work for me anyway,
:O)Good nighT
regsoft, i don't know of such a way except writing your expert for Delphi that will do the job... it is quite difficult to do that though.. I suggest you use something similar to what I proposed...

regsoftAuthor Commented:
Not what I was looking for - but it looks like that something like that is the only way.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.