Solved

Execute file long filenames

Posted on 1998-11-17
17
174 Views
Last Modified: 2010-04-04
I have a problem using execute file with long filenames, when the filename contains space(s) e.g.
"Long File Name.exe"
It executes properly, but then halts and gives a strange error reading.
(delphi3)
0
Comment
Question by:zonk
  • 4
  • 4
  • 3
  • +3
17 Comments
 
LVL 4

Expert Comment

by:erajoj
ID: 1347144
Just enclose it with quotation marks:

  "c:\program files\blab\myapp.exe"

?
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1347145
I mean:
 
  sPath := '"c:\program files\blab\myapp.exe"';
  DoWhateverYouWant( sPath );

/// John
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1347146
It is not nessesarily a problem of the quotes or the ShellExecute or whatever at all. I remember I installed one of my projects to "Program files\...", and it ran, but gave a handful of errors in the end. You can try: running the same program from Start/Run, and see if you get the same.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1347147
Oh, just to say that when I installed the project to some simple directory, like "C:\mydir", it ran perfectly. I never got to the root of the problem though. I think it was some db app...
0
 
LVL 17

Expert Comment

by:inthe
ID: 1347148
hello Zonk,
it is possible you could use the win32 api GetShortPathName to execute files in a long path.it returns the 8:3 dos format name for your long file name/path. like in dos you get progra~1 for program files directory
Barry
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347149
Zonk

I created a sample project with a lon file name and then created a second that executed the the first I used the shellexecute API and all's well that end's well in both D3 and D4

ShellExecute(Handle, 'open', 'Long File Name.Exe', '', 'C:\program files\testing\longfilename\', SW_SHOWNORMAL);

Does your execute code look like so, maybe post your execute code for us to take a look at.

Later
BoRiS
0
 

Author Comment

by:zonk
ID: 1347150
No, my instruction looks like this:
ExecuteFile ('name of the file.exe','','',1);

I will try shell execute, maybe that works.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347151
Hello y'all...

ShellExecute() will do the job for sure :)

Cheers,
Viktor
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:BoRiS
ID: 1347152
Zonk

If you use the Shell Execute command make sure you add ShellAPI to your uses clause

uses
Windows, Forms, ..., ShellAPI;
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347153
yup, that's what I'm talk'n 'bout ;-)

Cheers,
Viktor
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347154
John, how's everything going around ya??

Vik
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1347155
Still breathing...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347156
:)
0
 

Author Comment

by:zonk
ID: 1347157
So who gets the points now?
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347158
Zonk

Well did the ShellExecute I gave you work, Then the points are mine, but if one of the other examples worked then the points belong to them...

Later
BoRiS
0
 

Author Comment

by:zonk
ID: 1347159
Yes the shell execute works nicely.
And I gues Boris was the first to post, so post an answer and I will credit the points.
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1347160
Zonk

Here you go, just a simple answer, glad I could help...

Later
BoRiS
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi with SQL Natvie Client 15 85
Activex loadlibrary and show parented form issue 6 285
Thread safe  opinion 7 126
Dev Express grid collapse 2 39
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now