Dismissing network drives when unplugged

Networking, connecting to the internet, wi-fi and home entertainment
User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Dismissing network drives when unplugged

Post by Rudi »

Hi,

When I take my laptop home from work I run a small .bat file to close or dismiss network drives before I leave.
Image 037.jpg
If I forget to run the batch file, the PC keeps looking for these drives when I switch on the PC at home and takes a while to log on, or access windows explorer or the save/open dialogs because the drives are still mapped (even though I'm unplugged from the network).
Image 036.jpg
How do I get rid of these drives if I forgot to run the batch file while I was still plugged in? Running it while unplugged does not dismiss them?

TX
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
HansV
Administrator
Posts: 78443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Dismissing network drives when unplugged

Post by HansV »

Does the following command work?

MOUNTVOL /R
Best wishes,
Hans

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

Re: Dismissing network drives when unplugged

Post by Rudi »

Unfortunately not.
Regards,
Rudi

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

User avatar
HansV
Administrator
Posts: 78443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Dismissing network drives when unplugged

Post by HansV »

What happens if you restart Windows Explorer after NET USE * /DELETE?

taskkill /f /IM explorer.exe
explorer.exe
Best wishes,
Hans

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

Re: Dismissing network drives when unplugged

Post by Rudi »

TX Hans,

Back at work but will try when the issue happens again at home.
An initial test (at work) worked using the added script, but I'll only know for sure when I'm at home and outside of the work network that includes WiFi connectors too.

Cheers
Regards,
Rudi

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

User avatar
Claude
cheese lizard
Posts: 6241
Joined: 16 Jan 2010, 00:14
Location: Sydney Australia

Re: Dismissing network drives when unplugged

Post by Claude »

Can't you right-click on the names and delete ?
Cheers, Claude.

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Dismissing network drives when unplugged

Post by John Gray »

Would your home connection be any quicker if you had originally mapped the drives at work by server name rather than IP address? Perhaps 'Windows' would know more rapidly that it couldn't resolve the server names at home..
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

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

Re: Dismissing network drives when unplugged

Post by Rudi »

Hi

Claude; Nope that unfortunately does not work.
John; The mapping is done via a batch file that IT supplies so I don't want to tamper with this, but thanks for the suggestion as it could be useful for others that read the thread.
Regards,
Rudi

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

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

Re: Dismissing network drives when unplugged

Post by StuartR »

It would be simple if you run your batch file before you leave work, rather than after you arrive home.
StuartR


User avatar
HansV
Administrator
Posts: 78443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Dismissing network drives when unplugged

Post by HansV »

I'm sure Rudi is aware of that - see the first post in this thread...
Best wishes,
Hans

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

Re: Dismissing network drives when unplugged

Post by StuartR »

So he is.
StuartR


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

Re: Dismissing network drives when unplugged

Post by Rudi »

That is normally the case Stuart, but being human, sometimes I forget.

BTW: I had a windows task scheduled to do this; run the batch file when i closed the lid of my PC. It worked wonderfully before my PC crashed a few months ago but have not bothered setting this up again due to the technicalities in the scheduled task itself (since there is no "close lid" event and has to be simulated with other events). I don't have all the steps that I googled for when I set it up the first time. :groan:
Regards,
Rudi

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

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

Re: Dismissing network drives when unplugged

Post by StuartR »

That's interesting Rudi, I had looked at task scheduler events for this, but decided they wouldn't do the job!

What version of Windows are you running? I have a BAT file to connect all my drives, and a simple NET USE * /DEL is enough to remove them from explorer.
StuartR


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

Re: Dismissing network drives when unplugged

Post by Rudi »

I'm using Win 7 (64 bit) SP1

I use that same batch script to dismiss my drives, but it does not work when I'm at home and not plugged into the network of course. I'm not sure why these network map references are so persistent.

BTW: The last advice that Hans gave seemed to work this morning before I plugged in, but I'm still going to test it when I am at home too to confirm. So it might be resolved already.
Regards,
Rudi

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

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Dismissing network drives when unplugged

Post by John Gray »

Perhaps your original NET USE BATch file mappings should leave out the /p:y parameter or put /p:n, so that they are not persistent?!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

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

Re: Dismissing network drives when unplugged

Post by Rudi »

Hi John,

Removing the "/Y" changes the batch file to prompt if I want to apply the action to which I have to indicate N or Y. So that does not really change things.

Hans:
I purposefully did not run the original batch file so I could keep the drives and test at home.
The script below does the job; it kills explorer and reloads the taskbar. :thumbup:
HansV wrote:taskkill /f /IM explorer.exe
explorer.exe
Any idea why it removes the drives with this process?
Does it do a complete close and reload from the task manager?

Also, how would I change it to reload windows explorer because when I add what I thought was the syntax it load the window but the taskbar is missing?

TX
Regards,
Rudi

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

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Dismissing network drives when unplugged

Post by John Gray »

Rudi wrote:Removing the "/Y" changes the batch file to prompt if I want to apply the action to which I have to indicate N or Y. So that does not really change things.
Err - where did I say anything about /Y?
I was talking about the [abbreviated] /persistent:yes or /persistent:no ...! :hairout:
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

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

Re: Dismissing network drives when unplugged

Post by Rudi »

:blush: I clearly displays my neophyte status on anything network and batch file related.

So sorry.
I will test out your theory when the issue occurs again.
Can you give me the full script including the switches you indicate?

TX
Regards,
Rudi

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

User avatar
HansV
Administrator
Posts: 78443
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Dismissing network drives when unplugged

Post by HansV »

Rudi wrote:
HansV wrote:taskkill /f /IM explorer.exe
explorer.exe
Any idea why it removes the drives with this process?
Does it do a complete close and reload from the task manager?

Also, how would I change it to reload windows explorer because when I add what I thought was the syntax it load the window but the taskbar is missing?
These commands force Windows Explorer / File Explorer to start from scratch.
Does it or doesn't it show the taskbar after running?
Best wishes,
Hans

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

Re: Dismissing network drives when unplugged

Post by Rudi »

Your script shows the taskbar (and that's good); but my query was if it could also reopen file explorer?
When I modified the script it opened file explorer (the window) but explorer (the taskbar) didn't open.
Regards,
Rudi

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