Command to clear all Clipboard history in windows 10
I've scavenged the Google for a command to clear all the clipboard history but can't find any command for it, the only command is to clear the top to have it nulled/clean (not the entire clipboard history)
The reason for this is to create a task schedule to clear all the clipboard history when locking the user account.
The closest one is the CMD command:
cmd /c echo off | clip
But again this one just clear the current copy and paste and puts the recent copy and paste into history, this does not clear the clipboard history (at least on the latest Windows 10 patch, 2020-07-07)
So anyone that could help me find a solution for this would be greatly appreciated!
You can do this by stop and restart Clipboard service:
- In command-line:
for /f tokens^=2* %i in ('sc query^|find "Clipboard"')do >nul cd.|clip & net stop "%i %j" && net start "%i %j"
- In command-line with full path, name and extension:
for /f tokens^=2* %i in ('%__APPDIR__%sc.exe query^|find "Clipboard"')do >nul cd.|%__APPDIR__%clip.exe & %__APPDIR__%net.exe stop "%i %j" && %__APPDIR__%net.exe start "%i %j"
- In bat/cmd file:
for /f tokens^=2* %%i in ('sc query^|find "Clipboard"')do >nul cd.|clip & net stop "%%i %%j" && net start "%%i %%j"
- In bat/cmd file with full path, name and extension:
@echo off & title <nul & title .\%~nx0 & %__APPDIR__%mode.com con:cols=75lines=5
for /f tokens^=2* %%i in ('^<con: "%__APPDIR__%sc.exe" query^|find/i "Clipboard"
')do >nul cd.|%__APPDIR__%clip.exe && >nul (%__APPDIR__%net.exe stop "%%i %%j" ^
&& %__APPDIR__%net.exe start "%%i %%j")2>nul && Goto :EOF ||color 4f & Goto :^(
:^(
echo; & <con: echo\Ops! ERROR: Administrator rights are required to run: .\%~nx0
rem/; & <con: echo\Try re-launch it using: 'Run as Administrator' (Context menu)
rem/; & <con: rem/ && "%__APPDIR__%timeout.exe" /t -1 & color & cls && goto :EOF
- In powershell:
Restart-Service -Name "cbdhsvc*" -force
Obs.: 1. This commands (cmd/bat/ps1) requires administrator rights
Obs.: 2. For access to the Clipboard History GUI, use: V
Note: Thanks to @Sathyajith Bhat ♦ for Windows key kbd html tag sources
-
Some further reading:
[√] SC
[√] Net
[√] CMD /?
[√] For Loop
[√] For /F Loop
[√] NET START, STOP, PAUSE, CONTINUE - Manage Services
[√] Start-Service | refer:
PowerShell
[√] Stop-Service | refer:
PowerShell
[√] Restart-Service | refer:
PowerShell