Windows XP - DOS command - net use /delete how to force deletion even if files are in use

At the command prompt (Windows XP system), if I type in the command:

net use x: /delete /y

it will delete the drive mapping, but only if not in use.

is there a way to force the deletion *even if files are in use*??
(i know this can lead to other issues, but there is a specific reason why we need to do this).

thanks in advance.

LVL 9
sah18Asked:
Who is Participating?
 
Chris JamesConnect With a Mentor Commented:
To expand on leew's answer:

try:    openfiles /disconnect /id *

and then use your net use command to disconnect the drive.


0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
dj_ludachris.

You should know by now, you're not new here - posting of links alone is not appropriate without some kind of explanation... and your link alone is a help file for NET USE without addressing the actual question, as near as I can tell.

sah18,

You can use the openfiles command to close any existing open files and then use the net use command to disconnect the drive.
0
 
nixgibsCommented:
you  can do this with VB script

the parameter bForce will remove the drive even if it is in use
Dim WshNetwork
on error resume next
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive ("T:", bForce)

Open in new window

0
 
Joe VickI.T. Dept. AdministratorCommented:
I know this is an old problem, but another way I just found is to change directories back to c: before your net use delete.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.