Prevent access to the command prompt
Désactiver l’accès à l’invite de commandes
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.
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 DWordDisable
# 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 SilentlyContinueOptions (1)
| Label | Control | Registry value | REG type | Constraints / details | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Disable the command prompt script processing also?Désactiver également le traitement des scripts d’invite de commande ?DisableCMDScripts | Drop-down listenum | DisableCMD | REG_DWORD | Default choice (UI): #1
|