Click here to Skip to main content
14,981,862 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a program that I do not want to run by clicking the mouse on the executable file

And only run with the command of another program I have

What I have tried:

I have a program that I do not want to run by clicking the mouse on the executable file

And only run with the command of another program I have
Posted
Updated 23-Feb-21 11:48am

Basically, you can't. And exe is an exe is an exe - and there is not way an exe can tell how it was started.

About the only way you could do it is to pass an argument to the app which it would be very difficult to generate from a keyboard - the time in ticks hashed perhaps: but you'd have to check several different hash values to be sure it will run at all.

The other way is to create it as a DLL assembly instead of an EXE file and run it in a separate thread but as part of your existing process. DLL files can't be directly executed as they don't have a startup method.
   
Comments
Member 14013003 23-Feb-21 18:09pm
   
I have a client program and I have a client helper program and I want no one to be able to run it by clicking on the client helper program and the only thing that the client helper can run is the client

sorry for my english <3
merano99 23-Feb-21 18:34pm
   
Dont know if it possible in C#. In C or C++ you could check the arguments and if they dont fit exit the process without opening a window at all.
TX6430 23-Feb-21 18:49pm
   
Another possibility is that your program "maynotrun.exe" will have some user permission set to "deny execute" and this user will not be able to start this program by double click. However, using "run as" on the same "maynotrun.exe" will execute it, if another user will have an "execute" permission... Perhaps this is useful in this case, Cheers,
Not sure how to interpret your question, but, if the question is how to start an exe from a C# program without double clicking on this exe then it is possible to use System.Diagnostics.Process to start an exe

Process Class (System.Diagnostics) | Microsoft Docs[^]

However, prohibiting a double click on an exe is a different story, as OG stated above ...
Hope this helps
   

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