Clear Clipboard by using Command Prompt, Shortcut and Context Menu

On any computer system, in a layman language, when you copy or cut some content to paste somewhere, it is stored on RAM (volatile memory) for a short period until you copy or cut another content. Now if we talk about clipboard, you will get some idea of what it is and how it works. In the following section we will see how this function works on a Windows platform and how to properly clearing it easily using multiple methods.

Clipboard is a special zone in RAM used to store temporary data – images, text or other information. This RAM section is available for the current session users in all programs running on Windows. With the clipboard, users have the opportunity to copy and paste the information easily wherever users want.

When you copy or cut some content from your system, it stores in clipboard enabling you to paste it where you want. Thereafter, it transfers the information from clipboard to the place where you want to paste it. The point that you need to keep in mind that clipboard only stores 1 item at a time.

Technically, the clipboard is just a bit of physical memory (RAM) that has been set aside to hold any stuff that you might happen to copy or cut. It can only hold one item at a time, so when you cut or copy something, it replaces anything that is already in the clipboard.

You can keep pasting the contents of the clipboard as often as you like. Anything you put in the clipboard will remain there until you overwrite the contents by cutting or copying something else into the clipboard, or until you empty the clipboard by rebooting Windows.

In the previous version of the Windows operating system, you could have the option to see the clipboard content. The latest version of the operating system does not have this option.

However, if you still want to see your clipboard content, the easiest way is to paste the content that you have copied. If it is text or image, you can paste it on a word document and see your clipboard content.

What is wrong with keeping the clipboard content on your systems? Most of the people do not bother to clear their clipboard. Is there any problem or risk associated with this? For example, if you are using a public computer where you just copied some sensitive data and forget to clear it, anybody who uses that system again later can steal your sensitive data easily. Isn’t it possible? Now you got the idea why it is important to clear your system clipboard.

Clear Clipboard Using Command Prompt or Desktop Shortcut

Start with launching the Run dialog box by pressing Windows + R and then type the following command:

cmd /c "echo off | clip"

This command will replace the actual content of the clipboard with an empty space, so clearing the content that was included previously in the clipboard.

The above command clears the current clipboard memory, and works in all versions of Windows, including Windows 10. However, in Windows 10, the command doesn’t erase the new Clipboard history data (new feature introduced in Windows 10 build 1809): it will just clear the currently selected item from the memory, in the clipboard history list.

If we want to just a create a desktop shortcut to clear the clipboard memory we could use the following approach.

Right-click on Desktop and click on New and then choose Shortcut from the context menu.

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

Here in the location item section you need to paste the following command and click Next.

%windir%\System32\cmd.exe /c "echo off | clip"

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

Now you need to give a name to this shortcut whatever you want such as Clear Clipboard and click Finish.

Hotkey to Clear Clipboard in Windows 10

Press Windows + R and type the following command and press Enter: shell:Start menu.

We now will need to copy the shortcut created in the previous method in the opened folder.

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

Once the shortcut is copied, we need to right-click on the shortcut and select Properties option.

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

In the new opened window, we need to navigate to the Shortcut tab and click on the Shortcut Key option and assign a new key.

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

Once done, we will click Apply followed by OK to save changes. Now, we will be able to use the specified hotkeys to clear the clipboard directly from keyboard.

Clear Windows 10 Clipboard History using Shortcut (Service)

To clear the clipboard history via the graphical user interface we can use the WinKey + V to show up the History list and then click Clear all button at the top or going to Start → Settings → System → Clipboard → Clear as shown in the following screenshot:

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

This removes the clipboard history in the local computer as well as in your Microsoft cloud account. The pinned clipboard items are retained though.

To be able to accomplish the same procedure (purging all the clipboard items included in the Clipboard History) using a shortcut, all we need to do is restart the Clipboard User Service (a brand new service introduced by Microsoft with this new feature). First, we will need find out the the short service name of the Clipboard User Service.

  • Launch the Services MMC (services.msc).
  • Locate Clipboard User Service from the list.
  • Double-click Clipboard User Service and note down the service name (cbdhsvc and cbdhsvc_{machine_specific_id}).

Clear Clipboard by using Command Prompt, Shortcut and Context Menu

The service name contains a random string which varies from one Windows 10 computer to the other. Keep in mind that the cbdhsvc_4j381, for example, is just a child service of the main service, called cbdhsvc: these two system services can be found in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.

Open Notepad and paste the following two lines:

net stop cbdhsvc_4j381
net start cbdhsvc_4j381

Of course, you’ll have to replace cbdhsvc_4j381 with the actual name of the Clipboard User Service as in your system, then save the file as clear_clipboard.bat (or any other name, but always with .bat file extension).

When you want to clear the clipboard history, right-click on the batch file and click Run as administrator.

You could also schedule this service restart during the shutdown of the system, if you want.

Clear Clipboard using Powershell

The two following approaches can be used, in Powershell, to clear the clipboard content in Windows.

echo $null | clip.exe

The above code snippet is the most trivial. Then, we can use the .NET way of doing it.

Add-Type -AssemblyName System.Windows.Forms

The above snippet needs the Windows Forms namespace to clear the clipboard. Note that you don’t need to add the assembly if you are running the above code in PowerShell ISE.

We can also use the two available cmdlets in Powershell called Get-Clipboard and Set-Clipboard with which we can see and purge also the clipboard:

### Check clipboard content
Get-Clipboard -Raw

### Purge/Clean clipboard content
Set-Clipboard (with no arguments)
Set-Clipboard -Value $null

Get and Set Clipboard using VBScript

VBScript cannot handle directly the clipboard content, but with the following approach we can at least get and set the clipboard text content.

Function ClipText(input)

  If IsNull(input) Then
    ClipText= CreateObject("HTMLFile").parentWindow.clipboardData.getData("Text")
    If IsNull(ClipText) Then ClipText= ""
    CreateObject("WScript.Shell").Run _
      "mshta.exe javascript:eval(""document.parentWindow.clipboardData.setData('text','" _
      & Replace(Replace(input, "'", "\\u0027"), """", "\\u0022") & "');window.close()"")", _
  End If
End Function


'ClipText("Hello World!")

Result = ClipText(Null)
WScript.Echo Result

Clear Clipboard with Right-Click Menu (Windows 10)

The following approach involves the usage of a .reg file to import a custom right-click command on Windows 10. It is needed only the creation (or download the .reg file at the end of this article) of a .reg file with the following code, which use the command %windir%\System32\cmd.exe /c "echo off | clip" to clear the clipboard memory zone.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Clear Clipboard]
@="&Clear Clipboard"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Clear Clipboard\command]
@="\"C:\\Windows\\System32\\cmd.exe\" /c \"echo off | clip\""

This registry addition will let to use the Clear Clipboard command from any directory (including from Desktop) by just right-clicking on the background (selecting no files and/or folders).

The clip.exe command

The clip command copies all output from a command to the Windows Clipboard. You can then paste the Clipboard contents into to any Windows application, such as into Windows Notepad or Microsoft Word, typically by pressing Ctrl-V (or selecting menu item Edit > Paste) in that program.

The clip.exe command file comes standard with Windows Vista and newer versions of Windows. It does not come standard with earlier versions of Windows such as Windows XP. clip.exe program first appeared in the Windows 98 Resource pack, and then reappeared starting with Windows Vista.

To see if you have clip.exe on your computer, type clip /? and if it is not available, you will see an error: clip is not recognized as an internal or external command, operable program or batch file. This program is included in any version and edition of Windows 10.