In places where many devices are used together, sharing files and resources between computers is usually necessary. A popular method is using Samba (SMB) network shares. But sometimes, you might need to remove or forget your Samba or SMB credentials on your Windows 11 or 10 PC. This can be because you just want to keep things slightly more secure or to fix issues with connecting. This guide will show you how to do this safely, and also gives an alternative way using Command Prompt.
Also see: How to Update Network Drive Login Credentials in Windows 11
Forget Samba (SMB) credentials using Windows Credential Manager
Forgetting your stored Samba or SMB credentials can be easily done through the Windows Credential Manager. This tool lets you handle different types of credentials, including those for network file sharing. The following steps will show you how to do it for both Windows 11 and Windows 10.
- Press Win + S to open the Windows search bar.
- Type in Credential Manager and click on the result to open it.
- Go to the Windows Credentials tab.
- Scroll down to find the credentials for the Samba or SMB share you want to remove.
- Click the downward arrow next to the credential details to see more.
- Click the Remove button next to the details, and confirm your choice when asked.
This method makes sure the credentials are removed from your system, stopping automatic logins to those network shares later.
Pro tip: How to Share Folder in Windows 11/10 Without Password
Remove Samba (SMB) credentials using Command Prompt
If you’re good with command-line tools or need to write a script to remove credentials, using Command Prompt is another way. This method will use the net use
command, which is also pretty useful for network troubleshooting and some management.
- Press Win + X and pick Windows Terminal (Admin). If your Windows 10 is older, you might see Command Prompt (Admin) instead.
- First, it’s helpful to see all active network connections. Type
net use
and hit Enter. This shows all active network connections, including those using SMB or Samba. - Find the network share you want to remove credentials for. It will be listed as
\\ServerName\ShareName
. - Delete the network credentials:
- For network shares shown by server and share name, type the following command and hit Enter.
net use \\ServerName\ShareName /delete
Replace
\\ServerName\ShareName
with the real network share name you found earlier. - For network shares linked to a drive letter, type the following command, swapping
M:
with your drive letter.net use M: /delete
- For network shares shown by server and share name, type the following command and hit Enter.
- You might need to confirm the deletion. Type
Y
and hit Enter to continue. - To check if the network connection is deleted, type
net use
again and make sure it’s gone.
These commands will generally help you to manually remove the network share connection and clear the associated credentials. This is useful if you prefer using command lines for such tasks.
Linked issue: The Specified Network Password is Not Correct (Fix)
Some common issues you might encounter
Even if you follow the suggested methods, there are a few problems that you can run into while trying to remove or forget Samba (SMB) credentials in Windows 11 or 10.
Credentials persist after removal
Even after deleting credentials through either the Credential Manager or Command Prompt, you’re still able to connect to the network share without re-entering credentials.
Solution: Try restarting your computer to apply the changes. Windows sometimes caches credentials temporarily, and a reboot can clear that cache.
Related resource: Disable Network Level Authentication in Windows 11 or 10
Command Prompt returns an error
When using the net use
command to delete credentials, you encounter an error message like “System error 85 has occurred” or “The network connection could not be found.”
Solution: Make sure you are using the right format and spelling for the network share name (\\ServerName\ShareName
). Also, confirm you’re running Command Prompt as an administrator.
Credential Manager doesn’t show the network share
You’ve gone to the Windows Credentials tab in the Credential Manager, but the network share you want to remove credentials for isn’t there.
Solution: It might be because the credentials are in a different section like “Generic Credentials,” or linked to a specific app. Look carefully through all sections to find them.
Access denied after removing credentials
After successfully removing the credentials, you can’t reconnect to the network share and get an “Access Denied” message.
Solution: You may need to reconnect by entering new credentials. Go to the network share like usual, and when asked, type in the new username and password.
In a networked environment, controlling access to shared folders is essential. When using Windows 11, the operating system stores login credentials for network shares to streamline access. However, removing these credentials may be necessary to maintain security, resolve connectivity issues, or manage different user accounts.
Saved usernames and passwords for network shares are retained in Credential Manager, providing a centralized way to handle stored credentials. For command-line enthusiasts, cmdkey offers direct credential management from the terminal, giving administrators full oversight of the credentials used to access network resources.
Properly managing these Windows 11 credentials ensures that unauthorized access is prevented and that outdated credentials do not cause unexpected authentication errors. Maintaining clarity and control over stored login information is crucial in environments that demand precision and reliability.
Methods to delete saved username and password for network share in Windows:
-
Open Credential Manager through the Windows search bar.
-
Select the Windows Credentials tab.
-
Click on the dropdown icon for the server or computer that you want to remove from the Credential Manager.
-
Click on the remove link.
-
Confirm the deletion when prompted.
-
Repeat for other credentials as needed.
It might take a while for the credential to be removed from caches. You can either wait or reboot the system.
-
Open Command Prompt or PowerShell as an administrator.
-
List all the stored credentials.
$ cmdkey /list Currently stored credentials: Target: WindowsLive:target=virtualapp/didlogical Type: Generic User: 02erbobtpesylcou Local machine persistence Target: Domain:target=10.1.11.11 Type: Domain Password User: admin
-
Identify the credential associated with the network share.
Target: Domain:target=10.1.11.11
-
Delete the specific credential using cmdkey.
$ cmdkey /delete:10.1.11.11 CMDKEY: Credential deleted successfully.
-
Verify that the credential has been removed.
cmdkey /list
Discuss the article:
Comment
anonymously. Login not required.
If the cached network username and password are causing issues, follow these steps to completely remove network credentials in Windows 10.
When you first log into a network share, Windows can store those login credentials in the Credential Manager. This is called caching network credentials. Since the login credentials are already available in the Credential Manager, Windows will not prompt you again for the network share password or username. This makes the administrator or network user’s life easy as they don’t have to enter the username and password each and every time to access the network folder.
However, if the network share password is changed or if the initial username and password are wrong then the cached network credential can be a problem. In those cases, you can remove the network username and password from the credential manager.
In this quick guide, let me show the procedure to remove cached network credentials using Credential Manager and Command Prompt.
Remove Network Credentials from Credential Manager
Windows saves all the usernames and passwords in the Credential Manager. To remove the cached network password and username, you have to remove the network share entry from the Credential Manager.
Follow these steps to remove network credentials from the Credential Manager.
- Open Start.
- Search and open “Control Panel“.
- Set “View by” on top right corner to “Large icons” to see all control panel items.
- Click on the “Credential Manager” option.
- After opening the Credential Manager, select the “Windows Credentials” tab within it.
- Here, click on the Network Share password you want to delete.
- From the credential options, click the “Remove” link.
- Click “Yes” in the confirmation/warning window to confirm that you would like to remove the cached network password from the credential manager.
That is it. As soon as you click yes and confirm the action, Windows will remove network credentials. When you try to log into the network share, you will be again prompted for the username and password. If you select the Remember option, Windows will store the network share login details in the Credential Manager.
Use Command Prompt to Remove Cached Network Share Password & Username
To remove cached network share credentials, this is the command you should use. Once you execute the below command, Windows will delete all network share passwords.
net use * /DELETE
Follow the steps below to see how to use the command delete network share password in Windows.
- Open the Start menu.
- Search for “Command Prompt“.
- Right-click on Command Prompt and select the “Run as administrator” option.
- In the admin Command Prompt window, execute the “net use \\ServerName /del” command to delete a specific network share credentials. Replace “ServerName” with the actual network share computer name.
- To remove all cached network credentials use the “net use * /DELETE” command.
- Close the Command Prompt.
As soon as you execute the command, Windows will delete all network share passwords and usernames or a specific network share depending on the command you executed. If there are no cached network credentials, the Command Prompt will show the “There are no entries in the list” message.
I hope that helps. If you are stuck or need some help, comment below and I will try to help as much as possible.
—
If you like this article, check out how to map FTP as a network drive in Windows 10 and how to create network connections shortcut in Windows 10.
Диспетчер учетных данных Windows (Credential Manager) позволяет безопасно хранить учетные записи и пароля для доступа к сетевым ресурсам, веб сайтам и приложениям. Благодаря сохраненным в Credential Manager паролям вы можете подключаться без ввода пароля к сетевым ресурсам, которые поддерживаются проверку подлинности Windows (NTLM или Kerbersos), аутентификацию по сертификату, или базовую проверку подлинности.
Содержание:
- Используем диспетчер учетных данных Windows для хранения паролей
- Управление сохраненными учетными данными Windows из командной строки
- Доступ к менеджеру учетных данных Windows из PowerShell
Используем диспетчер учетных данных Windows для хранения паролей
Диспетчер учетных данных встроен в Windows и позволяет безопасно хранить три типа учетных данных:
- Учетные данные Windows (Windows Credentials) — учетные данные доступа к ресурсам, которые поддерживаются Windows аутентификацию (NTLM или Kerbersos). Это могут быть данные для подключения сетевых дисков или общим SMB папкам, NAS устройствам, сохраненные пароли для RDP подключений, пароли к сайтам, поддерживающих проверку подлинности Windows и т.д;
- Учетные данные сертификатов (Certificate-Based Credentials) – используются для доступа к ресурсам с помощью сертификатов (из секции Personal в Certificate Manager);
- Общие учетные данные (Generic Credentials) – хранит учетные данные для доступа к сторонним приложениям, совместимым с Credential Manager и поддерживающим Basic аутентификацию;
- Учетные данные для интернета (Web Credentials) – сохранённые пароли в браузерах Edge и Internet Explorer, приложениях Microsoft (MS Office, Teams, Outlook, Skype и т.д).
Например, если при доступе к сетевой папке вы включите опцию “Сохранить пароль”, то введенный вами пароли будет сохранен в Credential Manager.
Аналогично пароль для подключения к удаленному RDP/RDS серверу сохраняется в клиенте Remote Desktop Connection (mstsc.exe).
Открыть диспетчер учетных данных в Windows можно:
- из классической панели управления (Control Panel\User Accounts\Credential Manager, Панель управления -> Учетные записи пользователей -> Диспетчер учетных данных);
- изкоманднойстроки:
control /name Microsoft.CredentialManager
На скриншоте видно, что в Credential Manager хранятся два пароля, которые мы сохранили ранее.
Сохраненный пароль для RDP подключения сохраняется в формате
TERMSRV\hostname
.
Здесь вы можете добавить сохранённый пароль, отредактировать (просмотреть сохраненный пароль в открытом виде из графического интерфейса нельзя) или удалить любую из записей.
Для управления сохраненными паролями можно использовать классический диалоговый интерфейс Stored User Names and Password. Для его запуска выполните команду:
rundll32.exe keymgr.dll,KRShowKeyMgr
Здесь вы также можете управлять сохраненными учетными данными, а также выполнить резервное копирование и восстановление записей в Credential Manager (можно использовать для переноса базы Credential Manager на другой компьютер).
Управление сохраненными учетными данными Windows из командной строки
Вы можете добавить удалить и вывести сохраненные учетные данных в Credentil Manager из командной строки с помощью утилиты cmdkey.
Добавить в диспетчер учетные данные для доступа к серверу FS01:
cmdkey /add:FS01 /user:kbuldogov /pass:Passw0rdd1
Если нужно сохранить доменную учетную запись:
cmdkey /add:fs01.winitpro.local /user:[email protected] /pass:Passw0rdd1
Сохранить учетные данные для доступа к RDP/RDS серверу:
cmdkey /generic:termsrv/MSKRDS1 /user:kbuldogov /pass:Passw0rdd1
Вывести список сохраненных учетных данных:
cmdkey /list
Вывести список хранимых учетных данных для указанного компьютера:
cmdkey /list:fs01.winitpro.local
Удалить ранее сохраненные учетные данные:
cmdkey /delete:FS01
Удалить из Credential Manager все сохраненные пароли для RDP доступа:
For /F "tokens=1,2 delims= " %G in ('cmdkey /list ^| findstr "target=TERMSRV"') do cmdkey /delete %H
Полностью очистить пароли в Credential Manager:
for /F "tokens=1,2 delims= " %G in ('cmdkey /list ^| findstr Target') do cmdkey /delete %H
Также для управления сохраненными учетными данными можно использовать утилиту vaultcmd.Вывести список сохраненных учетных данных типа Windows Credentials:
vaultcmd /listcreds:"Windows Credentials"
Все сохраненные пароли хранятся в защищенном хранилище Windows Vault. Путь к хранилищу можно получить с помощью команды:
vaultcmd /list
По умолчанию это
%userprofile%\AppData\Local\Microsoft\Vault
. Ключ шифрования хранится в файле Policy.vpol. Клю шифровани используется для рашировки паролей в файлах .vcrd.
Для работы Credential Manager должна быть запущена служба VaultSvc:
Get-Service VaultSvc
Если служба отключена, при попытке получить доступ к Credential Manager появится ошибка:
Credential Manager Error The Credential Manager Service is not running. You can start the service manually using the Services snap-in or restart your computer to start the service. Error code: 0x800706B5 Error Message: The interface is unknown.
Если вы хотите заблокировать пользователям возможность сохранения сетевых паролей в Credential Manager, нужно включить параметр Network access: Do not allow storage of passwords and credentials for network authentication в разделе GPO Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options.
Теперь, если пользователь попытается сохранить пароль в хранилище, появится ошибка:
Credential Manager Error Unable to save credentials. To save credentials in this vault, check your computer configuration. Error code: 0x80070520 Error Message: A specified logon session does not exist. It may already have been terminated.
Доступ к менеджеру учетных данных Windows из PowerShell
В Windows нет встроенных командлетов для обращения к хранилищу PasswordVault из PowerShell. Но вы можете использовать модуль CredentialManager из галереи PowerShell.
Установите модуль:
Install-Module CredentialManager
В модуле всего 4 командлета:
- Get-StoredCredential – получить учетные данные из хранилища Windows Vault;
- Get-StrongPassword – сгенерировать случайный пароль;
- New-StoredCredential – добавить учетные данные в хранилище;
- Remove-StoredCredential – удалить учетные данные.
Чтобы добавить новые учетные данные в хранилище CredentialManager, выполните команду:
New-StoredCredential -Target 'contoso' -Type Generic -UserName '[email protected]' -Password '123qwe' -Persist 'LocalMachine'
Проверить, есть в хранилище сохраненные данные:
Get-StoredCredential -Target contoso
С помощью командлета Get-StoredCredential вы можете вывести сохраненный пароль, хранящийся в диспетчере учетных данных в отрытом виде.
Выведите список сохраненных учетных данных:
cmdkey.exe /list
Скопируйте значение Target для объекта, пароль которого вы хотите извлечь и вставьте его в следующую команду:
$cred = Get-StoredCredential -Target LegacyGeneric:target=termsrv/MSKRD2S1 [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($cred.Password))
Команда выведет сохраненный пароль в открытом виде.
Также для получения сохраненных паролей из credman в открытом виде можно использовать утилиты типа Mimikatz (смотри пример).
Сохраненные пароли из Credential Manager можно использовать в ваших скриптах PowerShell. Например, в следующем примере я получаю сохраненные имя и пароль в виде объекта PSCredential и подключаюсь с ними к Exchange Online из PowerShell:
$psCred = Get-StoredCredential -Target "Contoso"
Connect-MSolService -Credential $psCred
Также вы можете использовать Get-StoredCredential для безопасного получения сохранённых учетных данных в заданиях планировщика.
Также обратите внимание на модуль PowerShell Secret Management, который можно использовать для безопасного хранения паролей в Windows (поддерживает различные хранилища паролей: KeePass, LastPass, HashiCorp Vault, Azure Key Vault, Bitwarden.
Чтобы удалить сохраненные учетные данные из Windows Vault, выполните:
Remove-StoredCredential -Target Contoso
- Компьютеры
- Cancel
Как удалить сохранённый пароль к сетевой папке
Иногда необходимо удалить сохранённый пароль к сетевой папке. Windows позволяет ставить галочку при попытке создания подключения к сетевой папке на другой машине и не переспрашивает его в случае неверного указания пароля.
Ответ в том, чтобы воспользоваться командой
Пуск —> Выполнить —> control userpasswords2
и там найти вкладку с сохранёнными логинами и паролями типа такой:
Удаляем нужный…
И можно снова пытаться подключаться с правильным логином и паролем.
Ответ найден тут:
[решено] Как очистить данные (пользователь\пароль) подключения к компьютеру по сети
forum.oszone.net