RSS

How-to map network drives based on network location

This entry was posted on Apr 14 2009

This has been driving me crazy and I cannot figure out how to do it. Here is my problem:
I have a work laptop that I obviously use at work as well as at home. At work I have 6 network drives that are mapped automatically if I log into my computer while at work. At home I have a Windows Home Server with 5 shares that I wrote a batch script to connect to them when I get home. The WHS Connector also adds a shortcut to the shares on my desktop but I want the shares mapped so I can use them as local drives in programs. I also had to write 3 more scripts (1 to disconnect my work drives, 1 to connect my work drives, and 1 to disconnect my home drives) in case I go between work and home without fully turning off my computer and instead just putting it to sleep. I am fairly certain this problem can be fixed with AutoIT or some other tool but I am just surprised this sort of functionality isn’t built into ANY operating system. My laptop has Vista and Linux Mint on it but I know this functionality isn’t in OSX either.
Is there anyone out there that can can suggest something to accomplish this? All I want is something that monitors what network I am connected to, and if that network happens to be home or work, map the appropriate drives. I am going to work on this in AutoIT but I am open to suggestions if you have any.
As soon as I find more information or someone points me to a solution I will update this post with how it works.
Leave your idea’s in the comments.


One Response to “How-to map network drives based on network location”

  1. Hey there! I did a bit of searching around and I couldn’t find any pre-built applications that did this. Not to say that there aren’t any. Seems weird to me that someone hasn’t solved this once and for all already.

    My first thought when you said this was thinking back actually to what Shaun showed me of Windows 7 last night. It seems that since it allows you to associate a network with a pre-built environment of “Work” or “Home” that those should also allow you to curtail settings based on that configuration. But I still use Windows XP, so if there is something like that you would know more about it than I.

    However, barring that idea, I found this site over on Microsoft’s Tech Net: http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar08/hey0304.mspx (a piece of advice, after you read the question just scroll right down to the first code block, everything else is crap) showing you how to accomplish this using VB. It seems pretty sound, and I think that it would allow you to accomplish what you’re trying to do. He also does you the favor of explaining just about every line that he codes. In his example he maps/remaps the H drive to different locations, but you would just substitute that out with multiple drives for each of the case statements. Furthermore, I believe that this script would actually allow you to map both drives if you had access to both networks (vpn?) which would be super cool.

    I don’t know a whole lot about Windows programming, but ideally you would want to attach this script to some sort of network event so that each time you added or lost a connection it would re-evaluate your network drive setup, but apart from that you could also run it at startup, shutdown, or just put it on your desktop and double-click it from time to time.

    Let me know how this goes for you!


Post a Comment