28,655 questions
Hi,
You can create a group policy like Darrell mentioned above or use the Task Scheduler to create a task to run a specific command.
- Open Task Scheduler: You can do this by typing "Task Scheduler" in the Windows search bar and selecting it from the results.
- Create a New Task: In the Task Scheduler, click on "Create Task" in the Actions pane on the right.
- Name Your Task: Give your task a name and description that clearly indicates its purpose.
- Set the Trigger: Go to the "Triggers" tab and click "New". In the "Begin the task" dropdown, select "On an event". Then, set the "Log" to "System", "Source" to "User32", and "Event ID" to "1074". This event ID corresponds to system shutdown.
- Set the Action: Go to the "Actions" tab and click "New". In the "Action" dropdown, select "Start a program". Then, browse to the script or program you want to run when the system is shutting down.
- Configure Conditions and Settings: If needed, you can configure additional conditions and settings for your task under the "Conditions" and "Settings" tabs.
- Save the Task: Click "OK" to save your task.
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.