定期关闭程序

发布于 2024-09-16 06:25:37 字数 239 浏览 8 评论 0原文

我想终止名为 KnightOnline 的游戏的可执行文件并拒绝用户运行它。我正在使用:

Process.Start("taskkill.exe", "/f /im kol.exe");

但它显示了一个命令窗口。如何隐藏命令窗口,或者是否有另一种专业但臭名昭著的方法来拒绝不需要的程序?

编辑: 我编辑了主机并阻止了游戏的登录页面作为解决方案。

I want to kill an executable of a game named KnightOnline and deny user to run it. I'm using:

Process.Start("taskkill.exe", "/f /im kol.exe");

but it's showing a command window. How can I hide the command window, or is there another professional but infamous method to deny an unwanted program?

EDIT:
I edited hosts and blocked login page of the game as a solution.

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

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

发布评论

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

评论(4

花想c 2024-09-23 06:25:37

专业的方法是让用户知道某些正在运行的程序可能会产生冲突,并要求用户关闭它然后再继续。

连一句“我们道歉”都不说就默默地杀死它是邪恶的。

A professional way is to let the user know that some running program may pose conflicts and ask the user to close it before proceeding.

Killing it in silent without even saying "We apologize" is evil.

吃颗糖壮壮胆 2024-09-23 06:25:37

从一开始就不允许用户启动该程序是否会更好?

Windows 2000 及更高版本(XP、Vista、“7”)具有软件限制策略 - 允许您设置程序白名单或黑名单。如果是白名单,则仅允许启动列出的程序,而如果是黑名单,则允许启动除列出的程序之外的所有程序。此检查发生在操作系统级别,并且无法绕过(管理员除外)。有关示例,请参见

(黑名单的效率非常低,因为重命名可执行文件可以再次运行它;白名单需要更多的工作来纠正和管理 - 但大多数用户最多需要 20 个应用程序,再加上系统服务)

注意:并非所有版本的 Windows 都允许管理员要设置组策略、IIRC,您无法在 Windows XP Home 或 Vista Home Basic 中执行此操作。

而且,用户就是用户:你屏蔽本地游戏,他们就会玩Flash浏览器游戏;如果你阻止 Flash,他们就会玩浏览器内的 Javascript 游戏;如果你阻止它,他们就会玩纯 HTML 文本冒险游戏(同时对你无意中阻止了大多数其他网站的运行感到愤怒)。

如果你甚至阻止这一点,用户将放弃计算机并去吸烟,或者带上纸牌并玩纸牌现实生活,或者找到无数其他方法来逃避工作(假设我们正在谈论办公室用户) - 所以这不是一个胜利任何一个;除非您试图让用户离开计算机(从您的评论中可以看出)。

Would it be better not to allow the user to start the program in the first place?

Windows 2000 and up (XP, Vista, "Seven") have Software Restriction Policies - allows you to set a whitelist or blacklist of programs. In case of a whitelist, only the listed programs will be allowed to start, whereas with the blacklist, all except the listed programs will be allowed. This check happens at the OS level, and cannot be bypassed (except by Administrators). See e.g. this for examples.

(a blacklist is pretty ineffective, as renaming the executable allows running it again; whitelist is more work to get correct and to manage - but most users need at most 20 apps, plus system services)

Note: not all versions of Windows allow the administrators to set Group Policies, IIRC you can't do this in Windows XP Home or in Vista Home Basic.

Also, users will be users: if you block local games, they'll play Flash browser games; if you block Flash, they'll play in-browser Javascript games; if you block that, they'll play pure-HTML text adventure games (while being rightfully pissed that you have incidentally blocked most other websites from functioning).

If you block even that, the users will abandon the computer and go smoking, or bring in cards and play Solitaire IRL, or find a myriad other ways to avoid work (assuming we're talking about office users) - so that's not a win either; unless you're trying to get the user(s) off the computer (as it looks from your comments).

ま昔日黯然 2024-09-23 06:25:37

您可以使用 Process.Kill 来终止另一个过程:

foreach (var process in Process.GetProcessesByName("kol"))
{
    process.Kill();
}

You can use Process.Kill to kill another process:

foreach (var process in Process.GetProcessesByName("kol"))
{
    process.Kill();
}
慕巷 2024-09-23 06:25:37

如果您想在隐藏窗口中运行某些进程,请尝试以下操作:

var processInfo = new ProcessStartInfo() 
                      { 
                         Arguments = "/f /im kol.exe", 
                         FileName = "taskkill.exe", 
                         WindowStyle = ProcessWindowStyle.Hidden 
                      };

Process.Start(processInfo );

Try this if you want to run some process in a hidden window:

var processInfo = new ProcessStartInfo() 
                      { 
                         Arguments = "/f /im kol.exe", 
                         FileName = "taskkill.exe", 
                         WindowStyle = ProcessWindowStyle.Hidden 
                      };

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