CMDKEY.exe – Windows CMD Command
Create, list or delete stored user names, passwords or credentials.
/add Add a user name and password to the list.
TargetName The computer or domain name that this entry will be associated with.
/generic Add generic credentials to the list (used by RDC).
/smartcard Retrieve the credential from a smart card.
/user:UserName The user or account name to store with this entry.
If UserName is not supplied, it will be requested.
/pass:Password The password to store with this entry. If Password is not supplied, it will be requested.
/delete: Delete a user name and password from the list.
If TargetName is specified, that entry will be deleted.
If /ras is specified, the stored remote access entry will be deleted.
/list Display the list of stored user names and credentials.
If TargetName is not specified, all stored user names and credentials will be listed.
The credentials created by CMDKEY can also be created and edited in the GUI Control Panel | Credential Manager
Credentials setup as type /generic: TERMSRV will be used by Remote Desktop Connection, so you will be able to connect as the given user without being prompted for a password. If the password is changed you will need to update the stored credential.
By default the credentials are stored in C:\users\username\AppData\Roaming\Microsoft\Credentials\
(around 400 bytes per credential)
If more than one smart card is found, cmdkey will prompt the user to specify which one to use.
Once stored, passwords are not displayed by cmdkey.
Display a list of stored user names and credentials:
Add a generic TERMSRV credential for user PeteZ (on domain domF4T) to access the computer Server:
cmdkey /generic:TERMSRV/Server /user:domF4T\PeteZ /pass:p4g67hjyy23
Delete the stored TERMSRV credential for Server:
cmdkey /delete TERMSRV/Server
Add a user name and password for user Kate to access computer Server with the password z5rd63hGtjH7:
cmdkey /add:server /user:Kate /pass:z5rd63hGtjH7
Add a user name for user Kate to access computer Server and prompt for a password whenever Server is accessed:
cmdkey /add:server /user:Kate
Delete the stored credential for Server: