net use delete - open file

May 29, 2019 at 11:38:04
Specs: Windows, intel/8
Hi,

i have a batch script like this:

net use x: /delete

If there are open files from the network drive x, the cmd console ask whether the connection should still be disconnected (Y/N).

I know that I can force to disconnect the network drive (/yes), but I do not want that.

I would like to decide here what is done when a file is open and what is done when no file is open.

for example:

net use x: /delete
if there is an open file
do ...
if there is no open file
do ...

Is there a possibility here?

Thanks a lot and sorry for my bad english.


See More: net use delete - open file

Report •

#1
May 29, 2019 at 12:41:37
I found a solution now :)

net use x: /delete /no
IF ERRORLEVEL 1 (
goto error
) ELSE (
goto noerror
)


Report •

#2
June 17, 2019 at 04:30:54
Note that the errorlevel is a technical conclusion of the command, and that it does not report to you that a file is locked or not in that drive. It reports if it could delete the network mapping.

Report •
Related Solutions


Ask Question