Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a small script that runs on each workstation which runs defrag and chkdsk and connect each workstation temporarily to a network share that they, normally, do not have access to. The command I use to connect to them is:

net use \\server\sharename [password] /USER:domain\username P:No

Is there a command to log that user out of the drive share without restarting the computer?

Workstations run on Windows XP SP3

EDIT: I've used:

net use \\server\sharename /delete

but the command returns "The network connection cannot be found". However, I can still navigate to \\server\sharename in MyComputer address line and have full access to it still.

EDIT2: Assume I've read through the help files for net use ;D

EDIT3: Would a reboot suffice? Yes... however it is more convenient to log the user out of the share instead =D. I know I'm difficult.

share|improve this question
Have you tried Net Use * /Del? – Ƭᴇcʜιᴇ007 Aug 25 '11 at 17:20
we other user shares associated to the login, and we do not wish to remove all of them. Just the one that we've temporarily allowed the user access to. – Mechaflash Aug 25 '11 at 17:22
I (mostly) meant for testing purposes. But I think I see what's going on here, so I've added an 'answer'. :) – Ƭᴇcʜιᴇ007 Aug 25 '11 at 17:37
up vote 4 down vote accepted
net use \\server\sharename /delete

EDIT: To cause the credentials to get flushed:

net use \\server\IPC$ /delete
share|improve this answer
hmm, usually SU notifies me sooner if an answer is added when I'm typing, +1 for being first. – MaQleod Aug 25 '11 at 16:02
I've tried this, but the command returns "The network connection cannot be found." However, I can still access the network share freely.\ – Mechaflash Aug 25 '11 at 17:02
I'm so dumb... double checked my code this morning and found I had a trailing \ on after the sharename... tested it and yep the trailing slash makes a difference. Sorry for my n00bizm – Mechaflash Aug 26 '11 at 13:08
I tried net use \\server\IPC$ /delete and it gives the error The network connection could not be found. – druciferre Sep 23 '13 at 15:16
net use * /del can be used as a shotgun approach if you don't have any other connections you mind destroying (net use by itself will list them). After that, if it still doesn't work, restart the Workstation service instead of rebooting. – Jason C Feb 28 '15 at 1:57
net use \\server\sharename /delete

See the full net use command here.

share|improve this answer

If the net use commands listed here do not do the trick, instead of rebooting, you can just restart the Workstation service (I'm not sure how to do this without the service restart though):

  1. First use the appropriate net use commands as above (e.g. net use * /del for the shotgun approach).
  2. Control Panel -> Administrative Tools -> Services
  3. Find Workstation in the list.
  4. Right click and choose Restart.

If you have any explorer windows open for the shared folder, or any open files, you may have to close them in order for the service to restart (if the restart appears to hang this is usually why).

Alternatively you can restart the service on the command line with:

net stop Workstation
net start Workstation
net start "Computer Browser"

The Computer Browser start is usually necessary as stopping Workstation also stops Computer Browser. You'll see if it does in the output from the first command. Again, closing explorer windows and open files may be necessary.


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .