I'm looking for a way to unmap network drives when the screen saver turns on.

I have a few users that share an external, encrypted drive (Samba share, not windows) and they have a requirement to disconnect the drive mapping when the local machine is idle. I'd also like it to warn them if there are open files on the mapped drive, if possible.

There is also a requirement to force the password to be reentered before mapping when the machine comes back from idle.

Is there a Windows setting or utility out there in the wild that meets these requirements?


FWIW, I haven't seen an answer that makes me completely happy yet, so I'm not awarding the bounty...

  • How can you warn idle people? I'm sure it's possible, all I got from google was that anti-viruses used to act during screensavers.
    – tobylane
    Feb 10, 2011 at 0:16
  • @tobylane: I should have been more clear. I mean to warn them when they return from idle. This is in order to help them develop the habit to save files regularly so if I do force an unmap they lose minimal work.
    – JimR
    Feb 10, 2011 at 3:32

3 Answers 3


To break the net connection, just schedule a similar .bat file every few minutes :

@echo off
tasklist | find /i ".scr" && net use x: /delete

If necessary, you can hide the .bat file by using this answer.

But just to remark that I take no responsibility for what happens when the other users of this computer lose their work because of this disconnect.


This actually only works under 7, My bad.

You should be able to use windows scheduler to run a script to break the connection on a defined idle threshold. Or on lock, or unlock, whatever tickles your fancy.

(Control Panel->Admin Tools->Scheduler)

  • I see no option to run a command when the screensaver kicks in or the machine is locked. Am I missing something? These are WinXP machines.
    – JimR
    Feb 10, 2011 at 3:31
  • I know it works under 7, I will see if I can find it in my XP VM Feb 10, 2011 at 13:39
  • The options are actually not there under XP, oops. Feb 10, 2011 at 14:29

Even if you do find a nice way to disconnect the network drive every time they screensaver kicks in, it won't do what you want it to do.

  1. Windows remembers the credentials you used to mount a network share, until you log off. Furthermore, users can click "remember credentials" and it won't ever ask them at all. Even if you dismount the drive, as soon as they try to remount it, it will just use the cached credentials.

  2. Why would you want to do this anyhow? This will only serve to aggravate your users, and I see no way in which it will enhance security. You are much more likely to lose data from some disconnect-the-drive scheme than you are to lose it to some attacker who comes up to a computer while it's idle, steals sensitive data, and then runs away before anybody notices.

  3. When your users get ticked off that every time the screensaver turns on everything gets disconnected, they will turn off the screensaver. When you force a certain time limit on the screensaver, they will find a way around that too.

If your goal is to protect sensitive documents, you are much, much better off forcing users to enter their password when the computer resumes. This would allow them to keep documents open and not lose their place, leading to better productivity and happier workers. It's also super easy to do with tools built into Windows.

  • Funny as it seems, the users asked for this. There are only 2 of them in this case and the documents are their lifeblood. I'm working on a way to remove credentials as well. That's why there's an adjustment period where they want to be notified if there's an open document on the share.
    – JimR
    Feb 14, 2011 at 7:03
  • This makes no sense whatsoever. Just because your users ask for something irrational doesn't mean you should give it to them. Perhaps there's a better solution. Why exactly do they want to be disconnected every time? They think it will make it less likely that somebody will compromise their data?
    – nhinkle
    Feb 14, 2011 at 7:11
  • Also, depending on the software they're using, even if the share is disconnected, the document in use will still be loaded in memory and auto-save copies may be on the machine, so it's not like the files will disappear in the network drive is removed.
    – nhinkle
    Feb 14, 2011 at 7:14
  • When they are the ones paying you, you have to do what they ask. The disconnect is for legal reasons that don't make sense to anyone technical. I know Windows stores stuff without cleaning it up and sometimes leaves information vulnerable. I explained this and was asked to do it anyway.
    – JimR
    Feb 14, 2011 at 7:24
  • @JimR, fair enough then. If clients require something, sometimes you're just forced to do it. Best wishes for figuring out a solution that satisfies their demands.
    – nhinkle
    Feb 14, 2011 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.