Kill network drives when disconnected

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Kill network drives when disconnected

Post by Rudi »

Hi,

I use a laptop between work and home. A problem I am facing is when I close my laptop lid (putting it to sleep) and open it at home, it takes ages to open Windows Explorer as I assume it is trying to map all the network drives before opening Explorer. Is there a way to "kill" the network drives so that when I resume using the laptop at home, I do not need to wait ages (or reboot) before I can open/save files or open Windows Explorer?

Anyone know of a freeware app that would kill the drives automatically or if I can do something first before I close the lid (besides shut down)....

Any suggestions would be appreciated. TX
2013-07-26_13h00_17.png
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
Leif
Administrator
Posts: 7209
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: Kill network drives when disconnected

Post by Leif »

Can you reset the mapping to NOT reconnect at Logon?
x.jpg
You do not have the required permissions to view the files attached to this post.
Leif

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Kill network drives when disconnected

Post by Rudi »

TX. I've reset it without the checkmark. Let's see if that works when I get home tonight.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Kill network drives when disconnected

Post by StuartR »

You can manually disconnect all network drives by executing the command
NET USE * /DELETE
in a command window.

You could add this command to a text file, give it a .BAT extension instead of .TXT and then create a shortcut on your desktop that you can double click.
StuartR


User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Kill network drives when disconnected

Post by Rudi »

Thanks Leif and Stuart.

Stuart. This is working. It clears all the drives and when I got home, Explorer responded quickly.
Now I'm going to test it with a sleep. I prefer to have my laptop go into sleep mode when I close the lid. So on Monday O will test this process and see if it works as well as hibernate.

BTW: I changed the command to NET USE * /DELETE /Y (based on some readups on the command) so that it does not prompt. I'll see if that works too :smile:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Kill network drives when disconnected

Post by StuartR »

Here are a couple of .BAT files that I use to mount all my shared drives when I want to access them. This might save you a bit of time when you take the laptop back to work again.

The first file is called OneDisk.BAT it is called from the second file once for each disk that I want mounted.

Code: Select all

@echo off

rem   Map a single Disk drive.
rem     P1 = Drive Letter
rem     P2 = Folder that exists on that drive  (Use \ if you don't have a known folder name)
rem     P3 = Share Name
rem     P4 - (optional) /user:domain\username

If exist %1\NUL goto Exists
goto Deleted

:Exists
If exist %1%2\NUL goto Done
net use %1 /delete

:Deleted
Echo Mapping disk %1 to %3
Net Use %1 %3 %4

:Done
The second file is called WorkDisks.BAT and it maps all the drives I want mounted

Code: Select all

@echo off
@title %~n0

net use /persistent:NO

Call OneDisk J: \Forum "\\server.domain.com\share name with a space" /user:domain\StuartR
Call OneDisk K: \          "\\server.domain.com\sharename"
rem lots more similar lines go here

:finished
net use
pause
StuartR


User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Kill network drives when disconnected

Post by Rudi »

Tx. Appreciate the assistance.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.