How to Enable or Disable Enhanced Security and Performance for batch and CMD files in Windows 11
This tutorial shows you how to turn on or off enhanced security and performance for batch and CMD files in Windows 11.
To enable enhanced security and performance for batch files, add the LockBatchFilesWhenInUse DWORD value to 🗝️HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor and set it to 1. Set the value to 0 to disable this feature.
Why Would You Want to Do This?
Locking batch files while they are in use adds a security boost to your Windows 11 PC. This action helps stop anyone from accidentally or maliciously changing scripts while the batch files are running. Locking batch files prevents harmful code from altering active scripts, keeping your system safer.
Enhanced security for batch files in Windows 11 stops scripts from changing during execution. This protection prevents harmful code from altering running batch files. The feature helps keep your computer safe from malicious script modifications.
Enabling enhanced security and performance for batch files in Windows 11 requires a single file signature check per file. Without this mode, Windows checks each command's signature within a batch file individually. This single check significantly speeds up batch file processing and increases safety.
Policy authors can enable this mode by using the LockBatchFilesWhenInUse application manifest control, as documented in the Application Control for Business manifest schema.
What You Need
How to Enable or Disable This Feature
- [ADMIN PRIVILEGES REQUIRED] Add the following value to the Windows registry:
- Registry Key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor - Value name:
LockBatchFilesWhenInUse - Type:
DWORD - Data: Set to
0(disabled) or1(enabled)
- Registry Key:
The LockBatchFilesWhenInUse feature in Windows 11 manages security and performance for batch and CMD files. You can turn LockBatchFilesWhenInUse on or off by changing a setting in the Windows registry. You will need administrator rights. Add a value named LockBatchFilesWhenInUse to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor key, setting it to 0 to turn LockBatchFilesWhenInUse off or 1 to turn LockBatchFilesWhenInUse on.
Enable:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /v LockBatchFilesWhenInUse /t REG_DWORD /d 1 /f
Disable:
Windows 11 improves security and speed for batch and CMD files by preventing changes during execution. This prevents file tampering and also speeds up file loading. This protection feature, available in Windows 11, helps ensure file integrity.
Are .bat files still relevant today?
Yes, .bat files are still very useful for Windows users today, especially for automating everyday computer tasks and managing system settings.
What is %~ 1?
In a batch file, %~1 is a special syntax used to expand a command-line argument by removing any surrounding quotation marks. If the first argument passed to the script is enclosed in quotes, the tilde character strips them, ensuring the resulting path or string is processed correctly by subsequent commands.
How to enable command extensions in batch files?
Command extensions are usually on by default in Windows, but you can make sure they're active by adding 'setlocal enableextensions' to your script or by starting a new command prompt with 'cmd /e:on'.
What is the latest build of 25H2?
Windows 11 version 25H2 is currently in development and testing phases. As of the latest updates, the specific build numbers associated with this release include 26220.7934 for the Beta channel and 26300.7939 for the Dev channel. These builds introduce new security features, such as the LockBatchFilesWhenInUse setting for enhanced script protection.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!