Skip to content

Instantly share code, notes, and snippets.

@tomfanning
Last active May 8, 2024 09:18
Show Gist options
  • Save tomfanning/77f20a1bb50055e915f4 to your computer and use it in GitHub Desktop.
Save tomfanning/77f20a1bb50055e915f4 to your computer and use it in GitHub Desktop.
Batch file to clear all credentials from Windows Credential Manager
@echo off
cmdkey.exe /list > "%TEMP%\List.txt"
findstr.exe Target "%TEMP%\List.txt" > "%TEMP%\tokensonly.txt"
FOR /F "tokens=1,2 delims= " %%G IN (%TEMP%\tokensonly.txt) DO cmdkey.exe /delete:%%H
del "%TEMP%\List.txt" /s /f /q
del "%TEMP%\tokensonly.txt" /s /f /q
echo All done
pause
@BarisUygun
Copy link

BarisUygun commented May 8, 2020

I am not an expert too. But this can delete credentials under windows credential store i don't know if you can delete browser credentials.

@echo off
cmdkey.exe /list > "%TEMP%\List.txt"
findstr.exe Target "%TEMP%\List.txt" > "%TEMP%\tokensonly.txt"
for /F "tokens=1,* delims= " %G in ('cmdkey /list ^| findstr Adobe') do cmdkey /delete %H
del "%TEMP%\List.txt" /s /f /q
del "%TEMP%\tokensonly.txt" /s /f /q
echo All done
pause

@bharatuow
Copy link

Thanks for this. is there a way to only delete credentials from a specific source, say Adobe for example, using this script?

for /F "tokens=1,* delims= " %G in ('cmdkey /list ^| findstr Adobe') do cmdkey /delete %H

This worked for me!

Not working for me

@r-this
Copy link

r-this commented Aug 1, 2022

Thanks for this. is there a way to only delete credentials from a specific source, say Adobe for example, using this script?

for /F "tokens=1,* delims= " %G in ('cmdkey /list ^| findstr Adobe') do cmdkey /delete %H

This worked for me!

Thanks! This worked for me. I had to add an extra '%' to make it work, as follows:

for /F "tokens=1,2 delims= " %%G in ('cmdkey /list ^| findstr vscode') do cmdkey /delete %%H

@abu7midan
Copy link

@echo off
cmdkey.exe /list > "%TEMP%\List.txt"
findstr.exe Target "%TEMP%\List.txt" > "%TEMP%\tokensonly.txt"
FOR /F "tokens=1,2 delims= " %%G IN (%TEMP%\tokensonly.txt) DO cmdkey.exe /delete:%%H
del "%TEMP%\List.txt" /s /f /q
del "%TEMP%\tokensonly.txt" /s /f /q
echo All done
pause

@alpo67
Copy link

alpo67 commented May 25, 2023

Hi team I would like to add this command to the cleaning credentials bat file:
Go to the path %userprofile%\AppData\Local\Microsoft\Office\16.0\ and delete the folder named OfficeFileCache.

FOR /F "tokens=1,2 delims= " %%G IN ('cmdkey /list ^| findstr OfficeFileCache') do cmdkey /delete %%H

(I am not an expert, very sorry if sounds crazy)

@ham1tcagdas
Copy link

Hello Guys, i m glad to find some echo to remove credentials but i need it for ControlPanel\UserAccounts\CredentialManager\WebCredential what you write top of page is helps to remove WindowsCredentials. Can you help me to remove for WebCredentials? That saved on myComputer. i need it to fix this problem:
ApplicationFrameHost_IW2jtP5aNU
When i open my XBOX app and Trying to login previous friends logged in my pc their accounts keep appearing in this list and i want this list clean up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment