How to disconnect Samba
From NAS-4220
Contents |
If you need to access another share, which asks for a different user, you need to disconnect the actual connection.
There are three possibilities:
- The "easy way" is dead simple, but takes much longer than the "fast way".
- The "fast way" looks a bit complicated at first sight, but it actually is not.
- The "one-click way" takes a few minutes of preparation, but in the end it really takes just one click to disconnect your share.
1. The easy way
The easy way (speaking of windows) is to log off and then log on again.
2. The fast way
The fast way goes like this:
- open the command line
- Type
net use
now it depends, if you mapped your share or not.
- a mapped share will be shown with a drive letter in win-explorer as well as in your net use-list, where it will be shown under local
- an unmapped share will only be shown in network connections, but never with a drive letter.
2a. Disconnect a mapped share
- If you mapped your share, type
net use X: /delete
where
- "X:" is the name of the mapped drive you are using
Example for disconnecting a mapped share. Note the drive letter under local:
- That's it. You can now log on to your samba server with a new user name.
2b. Disconnect an unmapped share
- If you did not map a drive to the share, type
net use \\NAS4220\SHARE /delete
where
- "NAS4220" is the LAN-hostname or the ip-address of the box (check your list)
- "SHARE" is the name of the share you are connected to (also check your list)
Example for an unmapped share, connected to an ip-address:
Example for an unmapped share, connected to a LAN-hostname:
- That's it. You can now log on to your samba server with a new user name.
3. The one-click way
In order to understand this procedure, it is recommended, that you read & understand "the fast way" first and that you are able to disconnect your share by that way
The one-click way is nothing but the fast way, packed into a batch-file. It actually only makes sense, if you need to disconnect from the same share / network-drive many times, as it is not flexible and will only work with the one share, which is written in the batch-file.
The basic structure looks like this:
net use X: /delete
or this
net use \\192.168.X.Y\SHARE /delete
or this
net use \\NAS-4220\SHARE /delete
- take the piece of code, which is closest to your kind of connection,
- copy & paste it into win-editor
- modify it, that it will work with your actual connection (see "the fast way)
- safe the file, using the .bat extension on your desktop or any place you like
example:
disconnect_S.bat
Now, next time you need to disconnect from this specific share
- just double-click your .bat-file
- That's it. You can now log on to your samba server with a new user name.

