How to Disable Command Prompt – 5 Ways

The Windows operating system uses various built-in tools to configure and change computer settings. One such tool is the Windows command line. 

Using the command line (CMD.exe), the user can perform the necessary operations on his PC to solve the problem, change the settings of the operating system or installed applications. Using CMD, you can quickly and efficiently manage Windows settings.

In some cases, it is necessary to lock the command line on the computer to prevent the user from using this tool on the PC. To solve this problem, you first need to get an answer to the question of how to disable the Windows command line.

For some users, it may not be clear why you need to disable the command line on the device. There is an explanation for this.

This is necessary for security reasons to prevent the use of CMD.exe and the processing of scripts by batch files with “.cmd” and “.bat” extensions. As a result, the user will not be able to change Windows settings or programs on this computer.

Therefore, this prohibition is used in educational institutions or in enterprises where strict control over user actions is necessary. The computer administrator can restrict actions with the command line in order to protect this PC from possible incorrect actions by an inexperienced user.

The instructions in this article tell you how to disable the command line in Windows 10, Windows 8.1, Windows 8, Windows 7 in several ways using the built-in system tools.

How to disable the Windows command line in group policies – 1 way

The easiest way to accomplish the task of disabling the use of the command line is to use the built-in system tool – the Local Group Policy Editor. This method can be applied to older versions of Windows 10, 8, 7: Enterprise, Professional, Education, or Ultimate.

Home editions of Windows do not have a tool for editing group policies, but this restriction can be bypassed if desired. Read more about this in the article on this site at the link below.

Consider the whole process of blocking the command line on the computer in steps:

  1. Press the “Win” + “R” keys.
  2. In the Run dialog box, in the Open: field, type gpedit.msc (without the quotes).
  3. Press the “Enter” key.
  4. In the Local Group Policy Editor window that opens, follow the path:
User Configuration → Administrative Templates → System
  1. Locate the “Prohibit use of the command line” policy setting.
  2. Right-click on it, select “Edit” from the menu that opens.
  3. In the “Prohibit the use of the command line” window, set the option to “Enabled”.
  4. In the “Options:” area, in the “Prohibit also script processing on the command line” setting, specify “Yes” or “No”.

If you select “Yes”, then the command line will not work on the PC and scripts from batch files (CMD and BAT) will not be executed. If you choose No, only the command line will be locked, and batch file operations will be allowed to run.

  1. Click on the “OK” button,
  2. Restart your computer.

Immediately after launch, a message will appear in the command line interpreter window: “The command line prompt has been disabled by your administrator.” You must press any key to exit the CMD.exe application.

How to disable command line startup in the registry editor – method 2

Another option to prevent the use of the command line on a computer is to apply changes to the Windows system registry. The system tool, the Registry Editor, will help us with this, with which you can apply the necessary parameters to change the settings of the operating system.

This method works in all modern versions of the Windows operating system.

Before making changes to the system registry, create a Windows restore point, or backup the registry.

Do the following:

  1. Run Command Prompt as Administrator .
  2. Follow the path:

If there is no “System” partition, create a partition with this name: right-click on the “Windows” partition, select “New” in the context menu, and then “Partition”.

  1. Right-click on the free space in the area of ​​\u200b\u200bthe open section “System”.
  2. From the context menu, select “New” and then “DWORD (32-bit) Value”.
  3. Name this setting “DisableCMD”.
  4. Right-click on the parameter, in the menu that opens, click on the “Edit …” item.
  5. In the “Edit DWORD (32-bit) Value” window, in the “Value:” field, enter “1” or “2”, and then click on the “OK” button.

Value selection options:

  • “1” – block the command line and the execution of batch files (“.cmd” and “.bat”).
  • “2” – blocking only one command line, scripts using batch files can be executed.
  • “0” – the launch of the command line is not blocked.
  1. Reboot your PC.

Disabling the command line using a REG file – 3 way

Not all users are comfortable working in the registry editor. There is an easier way for them. Now you will learn how to disable the Windows 10, 8, 7 command line using a REG file.

The user will need to create a special REG file, after launching which the necessary changes in the Windows OS settings are applied to the PC.

To create a registry file do the following:

  1. Open Notepad on your computer.
  2. Add the following code to the application window – option 1 (disabling the command line and executing scripts with “.cmd” and “.bat” files):
Windows Registry Editor Version 5.00.


  1. Or apply these options – Option 2 (block command line only):
Windows Registry Editor Version 5.00.


  1. Enter the “File” menu, select “Save”.
  2. In the “File type:” field, select “All files”, and in the “File name:” field, enter any name with the “.reg” extension, for example, “disablecmd.reg”.
  3. Click on the “Save” button.
  4. Close the Notepad window.
  5. Right click on the created registry file.
  6. In the context menu, click on the “Merge” item.
  7. In the warning windows, agree to the application of changes in the Windows system registry.
  8. Reboot your operating system.

Blocking the launch of the command line using a BAT file – 4 way

A method similar to the previous one is to restrict the launch of CMD.exe using a batch file with the “.bat” extension. After running a specially crafted BAT file, changes are made to the registry of the Windows operating system that prevent the command line from running on the computer.

Go through the steps:

  1. Launch Notepad.
  2. Paste the following code into the application window if you need to prevent the PC from running the command line and using the “.cmd” and “.bat” batch files:
reg add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 1 /f
  1. This command prevents only the command line from running on the computer:
reg add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 2 /f
  1. After selecting one of the commands, from the “File” menu, click on the “Save” context menu item.
  2. Select in the “File type:” field – “All files”, and in the “File name” field – specify any name with the “.bat” extension, for example, “disablecmd.bat”.
  3. Exit Notepad.
  4. Right click on the created BAT file.
  5. In the context menu, you need to click on the item “Run as administrator”.
  6. Restart your PC.

Disabling in Windows PowerShell – Method 5

To disable the command line, you can use Windows PowerShell, a more advanced built-in operating system tool that performs similar functions.

Do the following:

  1. Start Windows PowerShell on the computer.
  2. In the shell window, enter the command that disables the use of the command line and the use of batch files “.cmd” and “.bat”:
REG add “HKCU\Software\Policies\Microsoft\Windows\System” /v DisableCMD /t REG_DWORD /d 1 /f
  1. If you need to disable only the command line, while allowing scripts to be executed using batch files, use this command:
REG add "HKCU\Software\Policies\Microsoft\Windows\System" /v DisableCMD /t REG_DWORD /d 2 /f
  1. Press the “Enter” key, close the PowerShell window.

Article Conclusions

Many users use the Windows Command Prompt to change operating system settings or to troubleshoot computer problems. In some cases, on a PC, it is necessary to restrict the user’s ability to access CMD. To do this, you need to block the use of the command line on the computer. This problem can be solved by various Windows system tools.

Leave a Reply

Your email address will not be published.