Solved

Execute file long filenames

Posted on 1998-11-17
17
173 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

20 Experts available now in Live!

Get 1:1 Help Now