views:

21

answers:

3

Hi everyone,

I'm wondering if there is a way (in Windows 7) to make some sort of mapping of drives so that sometimes you find the files in a network drive and sometimes you find them in a local map?
-And to be able to easily switch between those two.

The reason I want to do this is that I want to be able to work (as a developer, using Eclipse for Java) partly at work, where I have certain library files in a network drive, and partly on the train, where I can't access the internet, so then I need to have those library files in a local map on my laptop.

In my Eclipse projects I point out those library files using their whole file paths, and it's a lot of files and a lot of projects and I don't want to be forced to change every single filepath just because I'm temporarily working from a train.

I'm thinking that it would be great if I could map the same drive (say, drive "S"), so that it could either point to the place at the network or to a local map, depending on some easy switching.

How would you configure your environment in order to not change anything in your Eclipse project?

A: 

You could reference a those two paths on the same virtual drive with "subst".

That way, 'S:\' could refer to two different paths depending on your current workstation.

On workstation1:

subst S: c:\path1\to\files

On workstation2:

subst S: c:\path2\to\files

On your .classpath in both cases:

S:\yourFiles
VonC
+1  A: 

You could try SUBST

SUBST, substitute a drive letter for a network or local path. It basically creates a virtual drive with a local or a global (making this phrase sound more programmer-like) path.

Syntax:
      SUBST drive_letter: path //set the virtual drive path
      SUBST drive_letter: /D   //delete the drive

Another site!

Secko
@Secko: good suggestion, but I have a hard time to determine what it add to my (similar) answer.
VonC
@VonC Ouch, you changed your answer before I could post! I'll try either deleting mine or changing it. ;)
Secko
@Secko: you're right, I had initially mixed-up "net share" with "subst", so +1 to you ;)
VonC
@VonC Oh, thanks! But, you didn't have to do that!
Secko
A: 

Thank you for your answers, but I didn't really like 'subst', since the removal of the drive seemed to "remove the drive letter", so it couldn't be used again until I had restarted my computer.

A colleague of mine had found a solution that was just what I was looking for: Two VBScript files: One for changing the drive mapping to a local (but shared) folder, and one for changing to the remote folder. The files look like this:

Set objNetwork = CreateObject("WScript.Network")
on error resume next:
objNetwork.RemoveNetworkDrive "N:" , true, true
objNetwork.MapNetworkDrive "N:", "\\MYCOMPUTER\SHARED"

-This code is for changing to the local folder, but in the other file you just change the file path to the remote one.

Maybe this can help someone else who's having the same problem.

Ylva D