• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

Getting an executable with spaces in the name.

I have an application developed in Delphi 7 that I want to change the executable name for.

Normally I would do this through Save Project As, however I want the resulting executable name to have spaces in it, which is not allowed for a project name.

I thought about setting the Appliaction.exename property, but of course this is read only.

Anyone have any ideas how I can get an executable name with spaces in it?
0
Aaron_Schulz
Asked:
Aaron_Schulz
  • 5
  • 4
  • 2
1 Solution
 
StevenBCommented:
I don't mean to state the obvious, but did you think about simply renaming the executable file after building it?
0
 
GreenandroidCommented:
I would agree that StevenB's suggestion is the most obvious, however you could change the .exe name programatically.

For example :

var
  sExeOldName, sExeNewName : string;
begin
  sExeNewName:='Program Name.exe';                                    //New .exe name
  sExeOldName := ExtractFileName(Application.ExeName);         //Returns your applications current .exe name
  RenameFile( sExeOldName, sExeNewName);                          //Renames your .exe name
end;


Perhaps you could add this to the oncreate() method for your main form.


0
 
Aaron_SchulzAuthor Commented:
I have been manually renaming the executable up until now, but I'm sick of doing this every time I rebuild the application.
RenameFile( sExeOldName, sExeNewName);   does the job, but not until the first time the program is executed of course.  While this is helpful in a general sense, I have an install set I am producing which includes this program.  To automate this process I need the program compiled with the correct name.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GreenandroidCommented:
Hmm ok well instead of doing 'save project as', Go to PROJECT, then click on OPTIONS (or press Shift+ctrl+F11).  Click on the 'application' tab, and enter the desired .exe name into the 'title' box. This allows you to specify a name (with spaces allowed). When you compile your project, it will compile under the name you entered, so should eliminate the need to keep doing 'save project as'.
0
 
Aaron_SchulzAuthor Commented:
Sorry Greenandriod - love to give you the points for all the help, but I tried this ages ago.  Changing the Title changes the name of the application as displayed on the Taskbar, but not the executable name itself.
I have been doing some research on this - it seems most OS's apart from Windows do not allow file names with spaces.  Perhaps it is for cross-platform (Kylix anyone?) that Delphi does not allow this to be done.
0
 
StevenBCommented:
I suspect that the reason that Delphi does not allow it is that the file name of a delphi unit must match the unit name. Since spaces are illegal in Delphi identifiers they must also be illegal in a delphi unit filename. It would, I suppose, have been possible for Borland to include a project option to specify a different filename for the compiled executable, but as far as I can tell, they didn't and it simply can't be done in the Delphi IDE.
0
 
Aaron_SchulzAuthor Commented:
Thanks Steven - this is pretty much the conclusion I have come to as well.  I wonder if it's possible to hook into the Delphi IDE to write my own utility to do this (ie.  like VB allows).
0
 
StevenBCommented:
It would certainly be possible to write an IDE plugin package that did this, but personally I'd question the utility in devoting the required time to such an endevour, when it is so simple acheive the same ends with a batch file or similar :o)
0
 
StevenBCommented:
You can add an entry to the Delphi IDE tools menu with:

Tools -> Configure Tools -> Add

You could perhaps use this to add a simple call an executable to rename your file.
0
 
Aaron_SchulzAuthor Commented:
I think this is what I will do.  I'll write a batch file to do a command line build, and then call this batch file from within Delphi to do a build on that project, rather than using the IDE Build.

Pretty annoying Delphi can't produce an executable with spaces in it itself though.

Anyway, thanks for your help Steven.
0
 
StevenBCommented:
No worries, sorry we couldn't find a better solution.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now