Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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
1  
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
1  
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 2 days ago
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.


Reference: https://social.technet.microsoft.com/Forums/windows/en-US/58494ea1-e3a0-49ab-be5c-1aa2b86f13c9/how-to-logout-from-shared-folder

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.