- Batch files and PowerShell scripts allow you to automate cleaning, backups, networking, and maintenance in Windows 11 without the need for paid tools.
- WinScript makes it easy to generate advanced scripts to customize, uninstall bloatware, and adjust privacy and performance in Windows 10 and 11 using a graphical interface.
- A good set of scripts can also be used to audit security: users, firewall, services, RDP, scheduled tasks, BitLocker, or password policies.
- Combining these scripts with restore points and best practices results in a lighter, cleaner, more secure, and more privacy-friendly Windows 11.

If you use your PC daily, having a good collection of useful Windows 11 scripts on hand makes all the difference between wasting time repeating the same tasks and automating everything in just a couple of clicks. It doesn't matter if you're not a system administrator or a PowerShell expert: with a few well-prepared files, you can optimize your computer's performance, cleanliness, security, and even privacy.
In the following lines, we'll explore everything from classic batch files (.bat) for emptying the Recycle Bin or deleting temporary files, to more advanced tools like WinScript and utilities designed for system auditing, firewall checks, critical services, and hardening Windows 11 settings. Everything is explained in clear and straightforward language, so you can copy, adapt, and run each script effectively.
What is a batch file and why is it still so useful in Windows 11?
A batch file (.bat or .cmd) is essentially a text document containing one or more commands that Windows executes automatically, one after the other. Instead of typing each command into the command prompt, you write them once in a file and then simply run it when needed.
These types of scripts rely on the Command Prompt and PowerShell , but they don't require advanced knowledge: many tasks are reduced to just a few lines of code. When you run it, the system opens a console window, processes the instructions, and, if everything is correct, performs the action without asking for further confirmation.
Another important advantage is that batch files behave like a lightweight executable without dependencies : they don't require third-party applications, they work on virtually any modern Windows, and they usually only take up a few kilobytes, so you can save dozens or hundreds without worrying about space.
The only thing to keep in mind is that many scripts are more powerful when run with administrator privileges , as this allows them to access network, services, registry, or system folders. This is fine if you wrote the script yourself or it comes from a trusted source, but it also increases the risks when you don't know exactly what each line does.
How to create and run a .bat file in Windows 11
To create a basic batch file in Windows 11, all you need is the classic Notepad or any plain text editor. The process is straightforward, but it's a good idea to follow a simple routine to avoid silly mistakes that could ruin the script.
The first step is to open a text editor and paste or type the commands you want to automate . These commands can be internal Windows commands (such as del, rd, ipconfig, etc.), calls to external programs, or even PowerShell invocations if you want to delve deeper into advanced features.
Once you have the content ready, save the document with the .bat extension (for example, clean_temporaries.bat), making sure the editor doesn't add .txt at the end. In Notepad, it's important to choose "All Files" as the save type and type the full file name with the correct extension.
To run it, simply double-click the file, but there's a key difference: if the task requires accessing protected system files, you'll need to use the "Run as administrator" option from the context menu. In that case, User Account Control (UAC) will ask for confirmation before proceeding.
Remember that these files take up very little space and don't consume resources when they're not running, so you can create as many as you want for different tasks: cleaning, backups, network, maintenance ... It's like having your own custom shortcut panel.
Essential basic scripts for everyday use in Windows 11
There are a number of scripts worth keeping handy because they can handle frequently performed tasks in seconds. They're simple, safe if the paths are configured correctly, and save you several clicks every time you need to perform cleaning or maintenance.
Empty the recycle bin with one click
Instead of going to the desktop icon each time, opening the context menu, and confirming the deletion, you can create a small script that silently empties the Recycle Bin . This is usually done using a PowerShell command embedded within the .bat file itself.
The typical pattern would be: first, display an informational message; then, call the PowerShell command that empties the Recycle Bin by forcing its deletion; and finally, display another message indicating that the process is complete. Adding a pause at the end will allow you to check for any errors before the window closes.
Delete temporary system files
Windows 11 accumulates a large number of temporary files in the folder indicated by the %temp% variable . In the short term, this isn't a problem, but if weeks or months go by, these remnants can take up several gigabytes without you noticing, slowing down your SSD or internal storage.
With a script linked to that path, you can recursively and silently delete temporary files, forcing the deletion of locked files when it's safe to do so, and then clean up any empty subfolders. When finished, a simple message will confirm that everything is ready.
Launch multiple applications at once
Another very practical idea is to have a batch file that opens all the applications you use at the start of the day at once : file explorer, main browser, email client, code editor, etc. This way you avoid clicking on each icon or searching for shortcuts.
To do this, use the `start` command followed by the program name or the full path in quotation marks . You can include as many lines as you want; the script will launch each app in parallel and, at the end, will display a message like "Applications launched" with a pause so you can see if any path failed.
Script for folder backups
If you have a folder of documents, photos, or projects that you don't want to lose, it's very convenient to create a .bat file that automatically backs up all its contents to another location: an external drive, a second partition, or even a network folder.
A classic command for these tasks is xcopy, specifying the source folder, the destination folder, and a series of parameters to include subdirectories, hidden files, overwrite without prompting, and preserve attributes. With a single double-click, you'll have an updated copy of that critical directory without having to manually drag and drop files.
Reset local network settings
When your connection starts acting up and you don't know why, a good starting point is to reset your IP address, renew your DHCP lease, and clear your DNS cache . Doing this from the command line each time is a bit of a hassle, so a script saves a lot of time.
This type of batch file typically chains together several calls to ipconfig: one to release the IP address, another to renew it, and yet another to clear the stored name resolution. Combined with a "Network reset" message and a final pause command, you'll have a handy little network emergency kit always at hand on your desktop.
Create restore points quickly
Before messing with more aggressive scripts, modifying the registry, or uninstalling sensitive components, it's a good idea to create a Windows restore point . That way, if something goes wrong, you can revert your system to a previous state.
By calling system management tools (such as wmic) within a batch file, you can create a restore point with a custom name in seconds. This type of script is perfect for running right before performing a large set of optimizations or making drastic changes to your system.
Risks and best practices when using batch files
Everything that makes .bat files powerful also makes them a potential headache if used carelessly. A script can delete files en masse, change security settings, or modify the network in the blink of an eye, and a syntax error or a misdirected path can lead to disaster.
One of the most common dangers lies in deletion commands like del, erase, or rd /s /q . When used silently (without prompting for confirmation), a mistake in an environment variable or path can extend the deletion far beyond what you intended, even affecting folders you didn't want to touch at all.
The second major risk arises when you run scripts with administrator privileges . In that scenario, any poorly written—or malicious—instruction has free rein to affect services, the Windows registry, system directories like Windows or Program Files, and advanced network configurations.
In addition, many batch files downloaded from the internet can conceal malicious actions within seemingly harmless lines. A script that claims to clean temporary files, for example, could take advantage of the situation to download executables, open ports, or launch other less obvious PowerShell commands.
Therefore, the basic rules are clear: create the scripts yourself or use only completely reliable sources, check them line by line before running, mix them with frequent backups and restore points , and when in doubt, test first on a test machine (e.g., Windows Sandbox ) or a secondary installation.
WinScript: Automate setup and uninstallation in Windows 10 and 11
Beyond the usual .bat files, there are tools that take automation a step further. One of the most interesting is WinScript , an open-source project designed specifically to generate scripts that modify and customize a complete Windows 10 or 11 installation.
In essence, WinScript offers an interface very similar to the Windows 11 Settings app, but focused on advanced settings: privacy, telemetry, performance, gaming, pre-installed apps , and built-in features you might want to disable. It's all designed to let you create your own custom script without writing any code by hand.
Its main advantage is that you can use it both installed on the system and as a portable version , without needing to leave anything running in the background or consuming resources when you don't need it. The application is lightweight, free, and open source, making it attractive to users who want control without being tied to commercial solutions.
When you open WinScript, you'll see the different categories of settings that can be modified in the left panel, and the specific options for each section on the right. Next to each item is a toggle switch, allowing you to activate only the changes you want to include in the final script.
There are no predefined templates, so you'll need to go through each category to design a coherent set of changes. As you select options, WinScript automatically builds the resulting script , ready to run later on your own computer or on other PCs.
Once you've finished configuring everything, you can save the script file to a USB drive or other external storage device. This way, you can apply the exact same settings—uninstallations, privacy tweaks, performance adjustments—to any Windows 10 or 11 installation in a single process.
As an added help, the tool includes brief descriptions for each entry, so you know what enabling or disabling that setting entails. WinScript lets you remove both third-party bloatware and built-in applications, adjust telemetry and services, and even use its own function to create a restore point before making any changes—a highly recommended feature.
Scripts and commands for auditing Windows 11 security
In addition to optimizing performance or cleaning up leftover files, scripts are a highly effective way to perform a quick security audit in Windows 11. With a few well-chosen commands, you can check users, the firewall, sensitive services, scheduled tasks, and many other critical system points.
Some of the most common focuses in these checks include listing local users and administrators, checking the status of the firewall and Windows Defender , reviewing which services start automatically, checking active network connections, or inspecting security events in the event log.
It's also worth taking a look at the status of features like BitLocker and password policy , User Account Control (UAC) settings, the presence of outdated protocols like SMBv1, processes running from suspicious paths, and PowerShell execution policies that indicate how strict the scripting platform is.
Advanced aspects of a scripted audit include PowerShell logs , open listening ports, DNS settings, scheduled tasks that run automatically, inventory of installed software, particularly sensitive services (e.g., Remote Registry), TLS/SSL settings, and Windows Update-related events.
Other key aspects include Remote Desktop (RDP) settings , files loaded at automatic startup (startup folders, Run keys, and similar), account lockout policies, WinRM status (remote administration), and the detection of strange executables in temporary paths, which is very common in threats that abuse the Temp folder.
This entire check can be packaged into one or more PowerShell or batch scripts that, when executed, generate text or CSV reports with the results. This allows you to review, share, or compare statuses across different points in time to see if any recent changes have created an unexpected vulnerability in your security configuration.
Improve memory, remove junk files, and strengthen privacy in Windows 11
In environments where some installation requirements have been relaxed (for example, by using tools like Rufus to bypass certain hardware checks), it becomes even more important to keep the system clean, lightweight, and well-protected . If you also use several third-party utilities, you need to watch out for overlaps and side effects.
Tools like BleachBit, "sexy" scripts aimed at removing bloatware , privacy modules, disabling Windows features, utilities like O&O ShutUp, and panels like "Christitus Utility" are quite powerful, but it's advisable to combine them with controlled batch files and frequent restore points to minimize risks.
In terms of memory, in addition to disabling background programs and using end-task tools, it's advisable to use scripts that disable unnecessary services , review resource-intensive scheduled tasks, and adjust applications that start with the system. A small set of commands to list and modify these elements will help you recover RAM and CPU.
To safely remove residual files, you can combine your temporary and recycle bin scripts with regular cleanups of downloads, outdated logs, and folders where some applications leave large caches . Always proceed with caution and make sure not to delete active session data or settings you still use.
If the focus is on privacy, the key lies in reviewing telemetry, application permissions, services that send data to the cloud, and components that facilitate remote administration or excessive sharing . This is where both graphical tools like O&O ShutUp or WinScript and PowerShell scripts capable of changing group policies, registry keys, and hidden internal options come into play.
Finally, in terms of pure security, it's advisable to properly reinforce the firewall, strengthen the protection of Windows Defender (or your antivirus software), secure RDP, check open ports, limit SMBv1, and harden PowerShell execution policies. A good set of scripts designed to harden the attack surface can make all the difference on systems exposed to untrusted networks.
Having a collection of well-designed scripts for Windows 11, along with tools like WinScript and utilities focused on privacy and cleanup, allows you to transform a standard system—even one installed with relaxed requirements—into a highly refined environment: faster, with less junk, better protected against threats, and, above all, tailored to your workflow without having to manually repeat the same actions over and over.