Running app.

Posted on 2001-07-29
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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