6

kind of a weird question but how do I make a drive go from a OK state to disconnected state using net use? I do not want to delete it.

I am testing a script but the annoying thing is that to test the item I want I require a disconnected drive. I can't find anything anywhere as to how to do this.

If I do this:

net use X: /delete => then this deletes the drive.

I want the status of a drive to be "Disconnected"

Any ideas?

EDIT: I have taken the network offline and that disconnected a drive (i.e. the drive is now in a disconnected state)....not an ideal solution so if anyone has an idea where the network can remain online and I can make a drive "disconnected" that would be great!

lara400
  • 445
  • 2
  • 5
  • 13
  • Do you have access to the server/computer that's sharing the folder? You could use net session to terminate your session on the server/computer. – Jonathan Kortleven Jan 18 '16 at 14:02

3 Answers3

0

One possible workaround that comes to mind is to use pause between connecting and disconnecting the drive.

net use X: /delete
pause
net use x: \\pathToshare

The downside is that you will need to press a button on the screen that is running the script when you want the script to continue.

ArianM
  • 1
  • 1
0

You can restart the "Workstation" service, on the client computer.

net stop LanmanWorkstation
net start LanmanWorkstation
Swisstone
  • 6,357
  • 7
  • 21
  • 32
-2

Add server name with bogus IP address to hosts file. That should do the trick.

J-M
  • 1,492
  • 1
  • 9
  • 16