Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

How to protect one exe between two in c# .net windows application?

I am running other exe from my .net application.
I need, other exe should not be run directly from application directory.
It should run only through .net application.

How can we protect other exe using c# .net windows application?

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted
Comments
Prasad Avunoori 3-Jun-14 5:56am    
You mean the user should able to run the exe from .net only, right?
[no name] 3-Jun-14 6:00am    
Ya, Right.
[no name] 3-Jun-14 6:00am    
only main exe, other exe should not be run directly.
Prasad Avunoori 3-Jun-14 6:04am    
You are supposed to pass the command line arguments to the first exe from main exe. If that argument is valid then run the first exe, otherwise dont.

In first exe do the following stuff:

C#
static void Main(string[] args)
{
   
    if(args[0]=="someValuePassedFromSecondeExe")
    {
      Console.WriteLine("Welcome to exe 1")   
    }
  else 
   {  
   Console.WriteLine("Sorry!, you can run this exe1 from exe 2 only.")   
   }
}
 
Share this answer
 
Comments
[no name] 3-Jun-14 6:08am    
Where is write the code?
Prasad Avunoori 3-Jun-14 6:16am    
search your first exe's project with "static void Main", there you need to write the above code. Replace Console.Write() with some MessageBox.Show(). While you are calling exe1 from Main exe. you need to pass some arguments.
Prasad Avunoori 3-Jun-14 6:17am    
Read this: http://stackoverflow.com/questions/16029939/passing-arguments-one-by-one-one-in-console-exe-by-c-sharp-code
Hi Ankit,

Here is a another secure way to solve your problem : http://msdn.microsoft.com/en-IN/library/ms173139(v=vs.80).aspx[^]

But I wonder why you required that if you want to run it under your Exe only then please build it as a assembly and attach to your application.

If you have any difficulty to understand above example then please comment.


Thanks,
Suvabrata
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900