Running app.

Posted on 2001-07-29
Last Modified: 2010-04-06
How do you run another app. that is within your current app. exe folder and error check if it is?
Or how do you runn it if it is in a folder within your current app.exe folder?
Question by:Enej
  • 3
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6330880

  use shellapi to run the application, it will use the folder u r running ur program from as current folder and check about the file using FileExists

I hope that what are you looking for

Uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
  if FileExists('test.exe') then
    ShowMessage('This file is not exist in the current folder');

LVL 22

Accepted Solution

Mohammed Nasman earned 50 total points
ID: 6330889

  for better coding, use ExtractFilePath funcation tp get the folder for ur application that running.

uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
  Path : String;
  Path := ExtractFilePath(Application.ExeName);
  if FileExists(Path + 'test.exe') then
    ShellExecute(handle,'open',Pchar(Path + 'test.exe'),nil,nil,SW_ShowNormal)
    ShowMessage('This file is not exist in the current folder');

if you want to run a program within ur current folder just add this folder to the path string like :

  Path := ExtractFilePath(Application.ExeName) + 'test folder\';

Best regards
Mohammed Nasman


Author Comment

ID: 6330964
SellamAlleikum Mohammed,
It works OK .Thanks!
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6331080
wa alikum alsalam
I'm happy that's work with you :)

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

930 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

11 Experts available now in Live!

Get 1:1 Help Now