Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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!
 
Share this answer
 
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/[^]
 
Share this answer
 
Comments
Madzmar25 22-Aug-11 4:49am    
i want it to be coded because i want the disabling of the batch file will be done after the installation... it will run the script automatically so that the user wont have the hasle to go through the process of going to the registry or typing something just to disable the batch or cmd... i want it the program to do it...
Philippe Mori 22-Aug-11 20:03pm    
Doing that kind of things is normally done by the network administrator.

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