• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 41054
  • Last Modified:

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.

0
sah18
Asked:
sah18
1 Solution
 
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
 
Chris JamesCommented:
To expand on leew's answer:

try:    openfiles /disconnect /id *

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


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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now