How to use the command 'cmdkey' (with examples)

How to use the command 'cmdkey' (with examples)

The ‘cmdkey’ command is a powerful tool in Windows that allows users to create, show, and delete stored user names and passwords. This can be particularly useful in scenarios where multiple users need to access a server or when credentials for a specific target need to be managed.

Use case 1: Show a list of all user credentials

To show a list of all user credentials, you can use the following code:

cmdkey /list

Motivation: This use case can be handy when you want to quickly view all the user credentials stored on your Windows machine. It allows you to have a comprehensive overview of your stored credentials.

Explanation: The ‘/list’ argument is used to display a list of all the stored user credentials. When you run this command, it will show both the target name and the user name associated with each stored credential.

Example Output:

Currently stored credentials:

    Target: server1
    Type: Domain Password
    User: user1

    Target: server2
    Type: Domain Password
    User: user2

    ...

Use case 2: Store credentials for a user that accesses a server

To store credentials for a user that accesses a server, you can use the following code:

cmdkey /add:server_name /user:user_name

Motivation: This use case is useful when you want to store the credentials of a user who frequently accesses a specific server. By storing the credentials, the user does not need to enter them manually every time they access the server.

Explanation: The ‘/add’ argument is used to add or store new user credentials. The ‘server_name’ parameter specifies the name of the server you want to store the credentials for. The ‘user_name’ parameter specifies the user name for which you want to store the credentials.

Example Output:

Credentials were successfully stored for server_name.

Use case 3: Delete credentials for a specific target

To delete credentials for a specific target, you can use the following code:

cmdkey /delete target_name

Motivation: This use case is helpful when you want to remove stored credentials for a specific target. It is especially useful when you no longer want a user to access a particular target or when credentials need to be updated.

Explanation: The ‘/delete’ argument is used to delete stored user credentials for a specific target. The ’target_name’ parameter specifies the name of the target for which you want to delete the credentials.

Example Output:

Credentials for target_name were successfully deleted.

Conclusion:

The ‘cmdkey’ command provides a convenient way to manage stored user credentials in Windows. Whether you want to view all the stored credentials, store new ones for a user accessing a server, or delete credentials for a specific target, the ‘cmdkey’ command has got you covered. By using the examples provided, you can easily perform these actions efficiently and securely.

Related Posts

How to use the command 'Get-History' (with examples)

How to use the command 'Get-History' (with examples)

Get-History is a PowerShell command that allows users to display their command history.

Read More
Pueue Shutdown (with examples)

Pueue Shutdown (with examples)

Introduction Pueue is a command-line task management tool that allows users to manage and prioritize commands.

Read More
How to use the command 'join' (with examples)

How to use the command 'join' (with examples)

The join command is a powerful tool that allows you to join lines of two sorted files on a common field.

Read More