Maped Drive (by VB) won't unmap if Dir is opened on that drive

Status
Not open for further replies.
We have a VB .exe that takes a password, then
maps the S: drive with it's username/password.
Then when the .exe times out or is closed, it
disconnects the drive. Our systems are WinXP/Pro.

The problem is that if the drive is opened in
File Explorer when the disconnect code is run,
it opens a cmd window that says -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
"There are open files and/or incomplete directory
searches pending on the connection to S:.

Is it OK to continue disconnecting and force them
closed? (Y/N) [N]:"
- - - - - - - - - - - - - - - - - - - - - - - - - - -
If we enter "Y<cr)" in that window it closes, but
we need it to close without asking.

Bat file to map drive -
NET USE S: \\password /username
Bat file to clear drive -
NET USE S: /DELETE
>>> Works OK whether S: is open in File Explorer or not.

Current code in VB form to map drive -
X = Shell("NET USE S: \\password /username")
Current code in VB form to clear drive -
X = Shell("NET USE S: /DELETE")
>>> Only unmaps S: if is is not open in File Explorer.

tried using the /DELETE line with -
" /Y" yes
" /Q" Quiet Mode
" /-p" No Prompt

How can we close a mapped drive without regard
to it's current use status?

MacaRoon
 
Fixed - Added a 3 sec timer which then runs the disconnect cmd a second time.

This will work for us.
Thanks anyway.

Moderator, remove this post if you like.

tha MacaRoon
 
Status
Not open for further replies.
Back