Hello,
To run a batch file when Windows 11 shuts down, you can use the Task Scheduler to create a task that triggers on shutdown. Here are the steps:
Open Task Scheduler:
Press Win + S, type "Task Scheduler", and press Enter.
Create a New Task:
In the Task Scheduler, click on "Create Task" in the right-hand Actions pane.
General Settings:
Give your task a name and description.
Select "Run whether user is logged on or not".
Check "Run with highest privileges".
Triggers:
Go to the "Triggers" tab and click "New".
In the "Begin the task" dropdown, select "On an event".
Set the "Log" to "System", "Source" to "User32", and "Event ID" to "1074" (this event ID corresponds to system shutdown).
Actions:
Go to the "Actions" tab and click "New".
In the "Action" dropdown, select "Start a program".
In the "Program/script" field, browse to your batch file or type its path.
Conditions and Settings:
You can adjust conditions and settings as needed, but the defaults should work for most cases.
Save the Task:
Click "OK" and enter your password if prompted.
This setup will ensure your batch file runs whenever the system is shutting down.
Best Regards,
Hania Lian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.