I am working on a batch script to remap a network drive in windows xp. I have found it to work out well for the most part with:
net use G: /delete
net use G: \\file\share
However, if there are any connections to the drive, it will prompt:
There are open files and/or incomplete directory searches pending on the connection to G:.
Is it Ok to continue disconnecting and force them closed? (Y/N) [N]:
What would be the most graceful way of allowing for this dialog? Is there ever a case where forcing a disconnect would lead to trauma? Is there an alternative method of closing the connections, outside of deleting outright? Kick everything off the drive?
Unless there are actual files still being used on/from the mapped drive (shouldn't be if it's only being mapped to run a script, as long as the disconnect command is at the end) then there shouldn't be any problems forcing a disconnect. On the other hand, if there are files being read to/from the mapped drive, then you should expect some form of data loss.
I specify a force disconnect in my batch files by using:
This happens when files are still in use on the drive. I would strongly recommend closing all files and explorer windows that are open on the share before deleting it.
Forcing a disconnect with open files on the drive is akin to working on a file on the flash drive and then pulling it out while that file is still open. Data corruption galore.
This happens when you have no open connections in use on the drive as well. Double check your scripts to see if the connection is ever opened.