How to Automatically Clear the Windows 11 Clipboard History on Shutdown Using a Script

The Windows 11 Clipboard History feature (accessed by pressing Windows Key + V) is an incredibly powerful productivity tool. It allows you to copy multiple snippets of text, images, and links, storing them in a localized cache so you can paste them sequentially without constantly switching back and forth between applications.

However, this feature is also a massive privacy vulnerability. If you copy a password, a credit card number, or a sensitive personal email, that data sits in your Clipboard History completely unencrypted. If you share your computer with a family member or coworker, the next person to log in can simply press Windows Key + V and instantly view every sensitive item you copied during your session.

While you can manually click the “Clear all” button in the clipboard menu before you log off, it is incredibly easy to forget. Instead, you can use the Windows Local Group Policy Editor to run a silent script that automatically purges your entire clipboard history the moment you shut down your PC.

Step 1: Create the Batch Script

First, we need to create a simple script that forcefully clears the system clipboard cache.

  1. Right-click anywhere on your Desktop, select New > Text Document.
  2. Name the file ClearClipboard.bat (ensure you delete the .txt extension). If Windows warns you about changing the file extension, click Yes.
  3. Right-click ClearClipboard.bat and select Show more options > Edit (or open it with Notepad).
  4. Paste the following command exactly as written:
    cmd.exe /c "echo off | clip"
  5. Press Ctrl + S to save the file, and then close Notepad.
  6. Move this file to a safe, permanent location where it won’t be accidentally deleted, such as your C:\Windows\System32 folder or directly in the root C:\ drive.

Step 2: Open the Local Group Policy Editor

Note: The Group Policy Editor is only available in Windows 11 Pro, Enterprise, and Education editions. If you are using Windows 11 Home, you cannot proceed with this step.

  1. Press the Windows Key + R to open the Run dialog box.
  2. Type gpedit.msc into the text box and press Enter.

Step 3: Assign the Script to the Shutdown Trigger

We need to tell Windows to execute our script during the final stages of the log-off process.

  1. In the left-hand navigation pane of the Group Policy Editor, navigate to: User Configuration > Windows Settings > Scripts (Logon/Logoff).
  2. In the right-hand pane, double-click on Logoff.
  3. A new “Logoff Properties” window will appear. Click the Add… button.
  4. Click Browse… and navigate to the location where you saved your ClearClipboard.bat file (e.g., your C: drive). Select the file and click Open.
  5. Leave the “Script Parameters” box completely blank.
  6. Click OK to add the script, then click Apply and OK on the main properties window.

Step 4: Test the Automation

Close the Group Policy Editor.

To verify the automation works, press Windows Key + V and ensure you have several items populated in your clipboard history. Then, completely restart or log off your Windows 11 PC. When you log back in, press Windows Key + V again. The clipboard menu will pop up, but it will be completely empty, guaranteeing that your sensitive copied data is wiped clean at the end of every session.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.