To add to @ericbn 's https://stackoverflow.com/a/41111629/579827 here are sample commands I've embedded in a script I run to update all my passwords whenever they are renewed. It's probably not usable as-is as it's quite specific but it shows real life usage of cmdkey.exe
.
⚠ This is a shell script run in cygwin⚠
⚠ This works because I use private git repos that all authenticate with the same password (you probably don't want to loop over with the same credentials, but you may reuse this sample
/list
command to extract a list of already registered credentials) ⚠
entries=`cmdkey.exe /list: | grep git | sed -r -e 's/^[^:]+:\s*(.*)$/\1/gm'`for entry in ${entries}do cmdkey.exe "/delete:${entry}" cmdkey.exe "/generic:${entry}""/user:${GIT_USERNAME}""/pass:${GIT_PASSWORD}"done