Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@ion-storm

This comment has been minimized.

Copy link

ion-storm commented Jan 5, 2017

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

@ukmercanary

This comment has been minimized.

Copy link

ukmercanary commented May 2, 2019

Works great thanks alot!

@memehunter

This comment has been minimized.

Copy link

memehunter commented Jun 4, 2019

thank you :)

@loosetile2

This comment has been minimized.

Copy link

loosetile2 commented Oct 23, 2019

This works the finest. Thank you.
Just a quick one, if i run this from a command promt or called from another script, how do I make sure it's the logged in user that this runs for and not administrator. For example, using LogMeIn I may be logged into a users PC and when I run this, it gets run as an admin not as the user. Is there a way i can make sure the script runs as the....let's say currently active user rather than as administrator?

@tomfanning

This comment has been minimized.

Copy link
Owner Author

tomfanning commented Oct 23, 2019

@MarJone

This comment has been minimized.

Copy link

MarJone commented Nov 19, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.