Clear clipboard with .bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
findstr
Posts: 17
Joined: 09 Jun 2021 12:36

Clear clipboard with .bat file

#1 Post by findstr » 20 Jun 2021 20:32

Hello!
On my home computer I have a file effacer.ps1 on my desktop with contents

Code: Select all

Set-Clipboard $null
which clears Windows clipboard on double click.
At my work the computer refuses to run Powershell scripts, I can't change the execution policy.
Is there a way to achieve the same thing with cmd.exe: a file, which will clear the clipboard on double click?
Thanks!

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: Clear clipboard with .bat file

#2 Post by AR Coding » 20 Jun 2021 21:49

Code: Select all

echo off | clip

T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Clear clipboard with .bat file

#3 Post by T3RRY » 21 Jun 2021 01:40

AR Coding wrote:
20 Jun 2021 21:49

Code: Select all

echo off | clip
This merely writes an empty clip to the clip board. If clipboard History is enabled, previous clips will be viewable using WinKey + V
There are methods for resolving this in batch, however they require administrator access. See: https://superuser.com/a/1567434/1125492

To disable clipboard history, The reg value can be changed using the following command:

Code: Select all

reg add HKEY_CURRENT_USER\Software\Microsoft\Clipboard /v EnableClipboardHistory /t REG_DWORD /d 0x0 /f

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: Clear clipboard with .bat file

#4 Post by AR Coding » 21 Jun 2021 06:56

T3RRY wrote:
21 Jun 2021 01:40
AR Coding wrote:
20 Jun 2021 21:49

Code: Select all

echo off | clip
This merely writes an empty clip to the clip board. If clipboard History is enabled, previous clips will be viewable using WinKey + V
There are methods for resolving this in batch, however they require administrator access. See: https://superuser.com/a/1567434/1125492

To disable clipboard history, The reg value can be changed using the following command:

Code: Select all

reg add HKEY_CURRENT_USER\Software\Microsoft\Clipboard /v EnableClipboardHistory /t REG_DWORD /d 0x0 /f
I just did a simple search on Google and moSt websites that i clicked on said what i said

This was my search: How to empty clipboard cmd

T3RRY
Posts: 243
Joined: 06 May 2020 10:14

Re: Clear clipboard with .bat file

#5 Post by T3RRY » 21 Jun 2021 08:51

AR Coding wrote:
21 Jun 2021 06:56

I just did a simple search on Google and moSt websites that i clicked on said what i said

This was my search: How to empty clipboard cmd
Simple searches unfortunately do not uncover the details that testing does.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Clear clipboard with .bat file

#6 Post by Squashman » 21 Jun 2021 10:25


Post Reply