Click here to Skip to main content
15,886,046 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

How to run exe in Access Denied Permission Folder in c# .net windows application?

I have a set permission in application directory using code, it's running first time after installed application but if i rerun application so, exe did not run.

I have need for access denied permission on application directory or folder.

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted
Comments
Prasad Avunoori 30-Jun-14 6:13am    
Are you running one .exe from another exe?
[no name] 30-Jun-14 6:15am    
I have only an exe.
ZurdoDev 30-Jun-14 7:19am    
This is not clear at all.
[no name] 30-Jun-14 7:47am    
I have both exe(Internal & External) in an application. I want that only Internal exe can be accessible by users for run the application and
External exe can run through only Internal Exe.

1 solution

This again.

No, this is NOT going to work. You can NOT take permissions away from the user to stop them from running the second .EXE.

Why? Because everything is launched AS THE USER! If you launch Notepad, it runs AS YOU. It's not some special security context where the system runs Notepad.

So, if you take permissions away from the .EXE or from the folder that contains the .EXE, the user will NOT be able to find/run the .EXE.

AGAIN, you cannot prevent a user from running the second .EXE. They will always be able to launch it because the way you're designed this application MUST allow for the user to launch it. You cannot prevent them from launching the second .EXE outside of your application. It's that simple. If you launch the second .EXE from inside your application it is NO DIFFERENT than if the user launched it themselves by double-clicking on it.


Now, you can prevent the second .EXE from doing anything when it starts using a Mutex[^].

When your first application starts it creates a Mutex that it owns. When the second .EXE starts, the first thing it has to do is check to see if it can create this very same Mutex. If it can, the first .EXE is not running so destroy the Mutex and quit. If it can't, this means the first .EXE is running, so it can go on it's way and do whatever it is it needs to to.
 
Share this answer
 
v2

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