Page 1 of 1

Clear clipboard with .bat file

Posted: 20 Jun 2021 20:32
by findstr
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!

Re: Clear clipboard with .bat file

Posted: 20 Jun 2021 21:49
by AR Coding

Code: Select all

echo off | clip

Re: Clear clipboard with .bat file

Posted: 21 Jun 2021 01:40
by T3RRY
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

Re: Clear clipboard with .bat file

Posted: 21 Jun 2021 06:56
by AR Coding
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

Re: Clear clipboard with .bat file

Posted: 21 Jun 2021 08:51
by T3RRY
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.

Re: Clear clipboard with .bat file

Posted: 21 Jun 2021 10:25
by Squashman