如何在c#.net windows应用程序中的Access Denied Permission Folder中运行exe? [英] How to run exe in Access Denied Permission Folder in c# .net windows application?

查看:106
本文介绍了如何在c#.net windows应用程序中的Access Denied Permission Folder中运行exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



如何在c#.net windows应用程序中的Access Denied Permission Folder中运行exe?



我在应用程序目录中有一个使用代码的设置权限,它在安装应用程序后第一次运行但是如果我重新运行应用程序,那么exe没有运行。



I需要申请目录或文件夹的访问被拒绝权限。



请帮帮我。



谢谢提前。



Ankit Agarwal

软件工程师

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

推荐答案

这再次。



不,这不行。您无法取消用户的权限以阻止他们运行第二个.EXE。



为什么?因为一切都是作为用户发布的!如果您启动记事本,它会按您的意思运行。这不是系统运行记事本的一些特殊安全上下文。



因此,如果您从.EXE或包含.EXE的文件夹中获取权限,用户将无法找到/运行.EXE。



再次,您无法阻止用户运行第二个.EXE。他们将始终能够启动它,因为您设计此应用程序的方式必须允许用户启动它。您无法阻止它们在您的应用程序之外启动第二个.EXE。就这么简单。如果您从应用程序内部启动第二个.EXE,则与用户通过双击它自己启动它没有任何不同。





现在,您可以阻止第二个.EXE在使用开始时执行任何操作Mutex [ ^ ]。



当您的第一个应用程序启动时,它会创建一个它拥有的互斥锁。当第二个.EXE启动时,它要做的第一件事是检查它是否可以创建这个相同的互斥锁。如果可以的话,第一个.EXE没有运行,所以销毁Mutex并退出。如果它不能,这意味着第一个.EXE正在运行,所以它可以继续下去并做它需要的任何事情。
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.


这篇关于如何在c#.net windows应用程序中的Access Denied Permission Folder中运行exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆