在csharp中禁用批处理文件 [英] disable batch file in csharp

查看:85
本文介绍了在csharp中禁用批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家...我正在创建我的咖啡厅管理系统,我想禁用批处理文件,以便没有用户可以在其批处理文件上运行任何恶意代码...因此我打算禁用它...我要如何在C#中做到这一点?在此先感谢

解决方案

您可以通过注册表进行此操作:

键:HKEY_CURRENT_USER \ Software \ Policies \ Microsoft \ Windows \ System
名称:DisableCMD
类型:REG_DWORD
值:1 


这将禁用命令提示符和批处理文件的使用.要反转,请将值设置为0.
您可以使用注册表修改器在软件中进行设置,但是我很想通过组策略编辑器来做到这一点:
1)单击开始",然后单击运行",键入gpedit.msc,然后单击确定".
2)导航到用户配置\管理模板".
3)右键单击,然后选择添加模板"
4)在对话框中,选择系统",然后按添加".按关闭"
5)在左侧窗格中选择系统模板,阻止访问命令提示符"是右侧窗格中的选项之一.
如果您看的话,会发现也应该找到与您的咖啡馆相关的其他人-这部分是为什么我会推荐此路线而不是仅仅编写C#软件来做到这一点的原因!


不确定为什么您要通过代码来完成此操作,但是我相信可以在全局策略"上进行设置或操作注册表.请参阅以下链接.

http: //www.gpanswers.com/community/18-there-policy-setting-trick-x/1165-disable-running-batch-files-bat-through-policy.html [ http://www.pctools.com/guides/registry/detail/1143/ [ ^ ]


hi guys...im creating my cafe management system and i want to disable the use of a batch file so that no user can run any malicious code on their batch file... so im planning to disable it... how am i going to do it in c#? Thanks in advance

解决方案

You can do this via the registry:

key:   HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System
Name:  DisableCMD
Type:  REG_DWORD
Value: 1


This disables the command prompt, and the use of batch files. To reverse, set the value to 0.
You can set this in software by using teh registry modifiers, but I would be tempted to do this via the Group Policies Editor instead:
1) Click Start, Run, type gpedit.msc and click OK.
2) Navigate to User Configuration \ Administrative Templates.
3) Right click, and select "Add Template"
4) In the dialog, select "System" and press "Add". Press "Close"
5) Select the system template in the left hand pane, and "Prevent access to the command prompt" is one of the options in the right hand pane.
If you look, you will find others you should find relevant for your cafe as well - this is partly why I would recommend this route rather than just writing C# software to do it!


Not sure why you want to do it through code, but I believe its possible to set it on the Global Policy or manipulate the registry. See following links.

http://www.gpanswers.com/community/18-there-policy-setting-trick-x/1165-disable-running-batch-files-bat-through-policy.html[^]
http://www.pctools.com/guides/registry/detail/1143/[^]


这篇关于在csharp中禁用批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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