C# 防止我的​​ .exe win 应用程序被重命名?

发布于 2024-11-14 15:23:52 字数 261 浏览 4 评论 0原文

您好,是否可以防止我的 .exe 应用程序被重命名..?

这是我运行程序后的情况(我的问题)

(假设我运行 MyApp.exe) 可以说 Goodtime.exe

一个不友好的用户突然为了好玩,将我的 MyApp.exe 重命名为...之后 。他注销 Windows(xp),然后当我的程序尝试在启动时运行时 MyApp.exe ,我不会,因为它被重命名了,

是否可以通过代码来防止这种情况?

感谢任何愿意提供帮助的人=)

Hi is it possible to prevent my .exe application on being renamed..?

here is the senario(my problem)

After i Run my program, (lets say i run MyApp.exe)
a unfriendly user suddenly for fun, renamed my MyApp.exe to ... lets say Goodtime.exe

after that. he log-off windows(xp) and then when my program is attempting to run on startup
MyApp.exe , i wont because it got renamed

is it possible to prevent this through codes?

thanks to anyone who would help =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

哽咽笑 2024-11-21 15:23:52

你无法真正尝试阻止这一切。这是用户的计算机,如果他们想重命名计算机上的文件,他们可以这样做。

You can't really attempt to stop this. It's the user's computer and if they want to rename files on their computer they can do.

浮华 2024-11-21 15:23:52

那是不可能的。

然而,还有一种替代方法可以做到这一点。
您可以将用户设置为对其计算机的用户帐户拥有有限的权限。在这种情况下,他无法按照他想要的方式重命名文件。这是操作系统提供的限制,其中只有计算机的管理员才能对用户帐户设置这些限制。

编辑
我这里的意思是,如果您是计算机的管理员,作为替代方案,您可以手动限制登录计算机的用户的权限。为了更好地理解我的意思,请阅读我的帖子的回复。 :)

That is not possible.

However there is an alternative to do that.
You can set the user to have limited rights on his user account to the computer. In that case he cannot rename files in such a way he wanted. This is a restriction provided by the operating system in which only the administrators of the computer can set these restrictions to user accounts.

EDIT
What I mean here is if you are the administrator of the computer, as an alternative you can manually limit the privileges of the users who logs-in to the computer. For a better understanding on what I mean, please read the replies on my post. :)

只是一片海 2024-11-21 15:23:52

您可以将应用程序放置在用户不太可能去的地方并重命名它,例如程序文件文件夹中。但您无法阻止他们实际重命名应用程序。

You can place your application somewhere the user is less likely to go and rename it, like in the program files folder. But you can't stop them actually renaming the application.

十秒萌定你 2024-11-21 15:23:52

如果用户不是该计算机的管理员,默认情况下他们将无权重命名 Program Files 目录中的文件。人们希望不友好的用户不是目标计算机上的管理员(如果他们是,他们所做的事情可能比重命名一个应用程序文件更糟糕)。

If the user isn't an administrator on that machine they won't have permissions to rename files in the Program Files directory by default. One would hope that unfriendly users aren't administrators on the target machine (If they are, they can do a lot worse than renaming one application file).

白昼 2024-11-21 15:23:52

您可以在运行时检查可执行文件的名称。

但您无法阻止用户重命名它。

You can check what name the executable has when it's being run.

But you cannot prevent a user from renaming it.

画尸师 2024-11-21 15:23:52

您可以考虑使用 clickonce 发布。对于我的一生,我永远不能保证我可以在单击一次安装后找到红润的应用程序,这样可能会阻止您友好的用户弄乱该应用程序? ;-)

以下是有关 ClickOnce 发布< 的一些信息/a>.

本质上,编写一个应用程序,右键单击项目/解决方案,选择“发布”,然后按照向导操作。

它不能保证用户无法重命名和弄乱文件,但它会让事情变得更加困难。

You might consider using clickonce publishing. For the life of me I can never guarantee I can find the ruddy application after installing it with clickonce so that might stop your friendly user messing with the app? ;-)

Here is some info on ClickOnce Publishing.

In essence, write an application, right click the project/solution, choose "Publish", then follow the wizard.

It won't guarantee the user won't be able to rename and mess with the files, but it'll make it harder.

阿楠 2024-11-21 15:23:52
  1. 正如这里大多数人所解释的那样,通过权限方式。
  2. 愚蠢而浪费的方法是让一个守护进程(服务)自系统启动以来一直运行访问该文件。这样系统将不允许重命名该可执行文件,除非该守护进程被停止。
  1. By permissions way as most folks here explained.
  2. Stupid and waste method is to have a daemon (Service) running accessing this file all time since system boot. That way system wont allow this executable to be renamed unless this daemon is stopped.
一杆小烟枪 2024-11-21 15:23:52

您可以防止在运行时重命名或移动 exe 文件。
打开 exe 文件中的 exe 文件以进行读取并拒绝写入。
只要该文件运行,就保持其打开状态。

you can prevent renaming or moving your exe file while it is running.
Open the exe file within your exe file for reading and deny writing.
Keep this file open as long as it runs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文