Solved

How to disable batch file execution?

Posted on 2010-11-13
13
3,186 Views
Last Modified: 2013-12-04
I have a Windows Server 2008. How do I disable users ability to execute batch files?
0
Comment
Question by:deming
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 66

Expert Comment

by:johnb6767
ID: 34128999
Change the file association for .bat/.cmd to notepad....

Add it to a Machine Startup Script....
reg add "HKEY_CLASSES_ROOT\batfile\shell\open\command" /ve /d "c:\windows\system32\notepad.exe %1" /f

reg add "HKEY_CLASSES_ROOT\batfile\shell\runas\command" /ve /d "c:\windows\system32\notepad.exe %1" /f

reg add "HKEY_CLASSES_ROOT\batfile\shell\runasuser\command" /ve /d "c:\windows\system32\notepad.exe %1" /f



reg add "HKEY_CLASSES_ROOT\cmdfile\shell\open\command" /ve /d "c:\windows\system32\notepad.exe %1" /f

reg add "HKEY_CLASSES_ROOT\cmdfile\shell\runas\command" /ve /d "c:\windows\system32\notepad.exe %1" /f

reg add "HKEY_CLASSES_ROOT\cmdfile\shell\runasuser\command" /ve /d "c:\windows\system32\notepad.exe %1" /f

Open in new window

0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34129009
Did you test that on the command line?

Because on the command line, I would expect you'll need to alter your system wide environment variables so that PATHEXT no longer lists .BAT or .CMD.
0
 

Author Comment

by:deming
ID: 34129027
Is there a Group Policy I could change to prevent batch/command files?
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34129040
Out of curiousity... WHY are you doing this?  It doesn't make much sense to me.  Batch files are important network administration tools and can make things easier for users... Perhaps there's a better way of accomplishing your end goal, if you can define what, exactly, the end goal of disabling batch scripts is.

(And I know of no group policy to disable batch files... never looked into it... )
0
 

Author Comment

by:deming
ID: 34129077
My server has a security app running which I do not want shut down. Users are downloading batch files via FTP to the server and then executing these batch files which then are trying to kill my security app.

So I am trying to shut down FTP access (in another question) and shut down the ability to execute batch files.  
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34129084
A batch file is just commands... In my opinion, you are focusing on the wrong thing.

Who are these users?  Why are your own users attacking you?  Or do you mean hackers are hacking your system?

Your USERS should not have the right to terminate the process stop the service.  Then the batch file becomes irrelevant.  Why do you give your users admin rights?  Take those away and the batch file won't matter.
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 66

Expert Comment

by:johnb6767
ID: 34129099
I tested launching a .bat file, and it opened it notepad......

I do agree with leew though, it is not the right way to prevent what you are trying to do..... Does anwer the actual question though...

:)
0
 

Author Comment

by:deming
ID: 34129159
I am looking at worst case and thinking ahead. They are my users (standard rights) but they may have bad intentions at some point. One user pointed out that he could download batch files via FTP and execute them and thought I should close that hole.

So I am working on disabling FTP access. But I also wanted to prevent execution of batch files in case some gets one onto the computer.

0
 
LVL 66

Expert Comment

by:johnb6767
ID: 34129170
And leew, you were correct, the cmd line still ran the batch files......

Standard users shouldnt be able to close processes running on a server though.....
0
 
LVL 77

Expert Comment

by:arnold
ID: 34129305
Limit the users on the server (limited/restricted user) and maintain the system with the most current updates.

You can as others mentioned define a rule for IE not to download items.

that match a certain patern i.e. no vbs, bat, exe, etc.  if you have a firewall/porxy, you can define the rule on those There would be a load impact for URL rejection on the firewall/router..
0
 
LVL 5

Expert Comment

by:balmasri
ID: 34130626
-Using Group policy , disable *.bat [ Enable GPO>User configuration>Administrative Templates>System >Don't run specified Windows applications >*.bat

OR
- GPO>User configuration>Administrative Templates>System >Prevent access to the command prompt
0
 
LVL 5

Accepted Solution

by:
xylog earned 500 total points
ID: 34139158
GPO should work, but failing that you can also adjust ntfs ACL's on cmd.exe to deny a particular user group or only allow administrators.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No security measures warrant 100% as a "silver bullet". The truth is we also cannot assume anything but a defensive and vigilance posture. Adopt no trust by default and reveal in assumption. Only assume anonymity or invisibility in the reverse. Safe…
Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now