how to know how iam running the exe....

Posted on 2005-03-14
Medium Priority
Last Modified: 2013-11-20
hi all,
i have two exe files(exe1 and exe2)...i can run exe2 from exe1... and also run exe2 seperately......i want to know whether my exe2 is being run independently or from exe1....

please help me to solve this problem

Question by:yateesh
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
  • 2
  • 2
LVL 44

Expert Comment

ID: 13533289
The two processe are separate so there is no native way to determine what you want.
However if you launch exe2 from exe1 you could pass a command line parameter that would allow you to determine that exe2 was launched from exe1 (that command line param would not be available when you launched it independantly, eg. -z12345)

Author Comment

ID: 13533985
can u send me an example showing how to do it.....
LVL 44

Accepted Solution

AndyAinscow earned 400 total points
ID: 13534112
ShellExecute(NULL, "open", "C:\\myapp1.exe", "-z12345", "c:\\", SW_SHOWNORMAL);

end in exe2 (InitInstance)

CString str2Param;
if ( __argc >= 2 )
   str2Param = __targv[1];    str2Param should now be "-z12345"

Expert Comment

ID: 13536006

Use a CMutex : Create it in exe1
in exe2 : if you try to create the same mutex, os will tell you that mutex already exists and so that exe1 is running ...

Author Comment

ID: 13581108
hi Andy,
if i hav invoked exe2 from exe1.....
i hav to kill exe2 when exe1 exists...
how can i do that


Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
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