Open in the explorer

Prevent access to the command prompt

Désactiver l’accès à l’invite de commandes

Type
User
GPO path
User Configuration › Policies › Administrative Templates › System FR: Configuration utilisateur › Stratégies › Modèles d'administration › Système
Supported on
At least Windows 2000 FR: Au minimum Windows 2000
ADMX file
Shell-CommandPrompt-RegEditTools.admx
Internal name
Shell-CommandPrompt-RegEditTools/DisableCMD

Explanation

This policy setting prevents users from running the interactive command prompt, Cmd.exe. This policy setting also determines whether batch files (.cmd and .bat) can run on the computer.

If you enable this policy setting and the user tries to open a command window, the system displays a message explaining that a setting prevents the action.

If you disable this policy setting or do not configure it, users can run Cmd.exe and batch files normally.

Note: Do not prevent the computer from running batch files if the computer uses logon, logoff, startup, or shutdown batch file scripts, or for users that use Remote Desktop Services.

French text from Windows 11 26H2

Ce paramètre de stratégie empêche les utilisateurs d’exécuter l’invite de commandes interactive, Cmd.exe. Ce paramètre de stratégie indique également s’il est permis d’exécuter ou non les fichiers de commandes (.cmd et .bat) sur l’ordinateur.

Si vous activez ce paramètre de stratégie et que l’utilisateur essaie d’ouvrir une fenêtre de commande, le système affiche un message signalant qu’un paramètre bloque l’action.

Si vous désactivez ou ne configurez pas ce paramètre de stratégie, les utilisateurs peuvent exécuter normalement Cmd.exe et des fichiers de commandes.

Remarque : n’empêchez pas l’exécution des fichiers de commandes sur l’ordinateur si celui-ci utilise des scripts de fichiers de commandes pour la connexion, la déconnexion, le démarrage ou l’arrêt, ou pour les utilisateurs ayant recours aux services Bureau à distance.

Registry

HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System
Value name
not defined in the ADMX

Enable / disable values: not defined in the ADMX (see the options below).

PowerShell

PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.

Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.

Enable

# Enable: Shell-CommandPrompt-RegEditTools/DisableCMD
$k = 'HKCU:\Software\Policies\Microsoft\Windows\System'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
# Disable the command prompt script processing also?
# Possible options:
#   Yes = 1
#   No = 2
Set-ItemProperty -Path $k -Name 'DisableCMD' -Value 2 -Type DWord

Disable

# Disable: Shell-CommandPrompt-RegEditTools/DisableCMD
# No value is written in the "Disabled" state (nothing defined in the ADMX)

Revert to "Not configured"

# Revert to "Not configured": Shell-CommandPrompt-RegEditTools/DisableCMD
$k = 'HKCU:\Software\Policies\Microsoft\Windows\System'
Remove-ItemProperty -Path $k -Name 'DisableCMD' -ErrorAction SilentlyContinue

Options (1)

LabelControlRegistry valueREG typeConstraints / details
Disable the command prompt script processing also?Désactiver également le traitement des scripts d’invite de commande ?DisableCMDScriptsDrop-down listenumDisableCMDREG_DWORD
Default choice (UI): #1
LabelValue
YesREG_DWORD = 1
NoREG_DWORD = 2

Availability