"Clearcase, Rational, clearCase consulting, Jazz tools consultant, ABS, training, GSA, Rational, IBM, GSA, BM Rational Tools consultant, Clearquest, ClearCase training, CM, scm, ClearCase help, consulting, trainer, training, ClearCase guru, configuration management" "RTC, Rational Team Concert, clearcase, CLEARCASE resume, trainer, consultant, clearcase, BM Rational Tools consultant, ClearCase training, GSA contract holder, Rational, IBM, CM, scm, ClearQuest Consulting, ClearCase help, consulting, trainer, training, ClearCase guru, configuration management" "ClearCase training, RTC, Requisite Pro, JAZZ, ABS, GSA Schedule holder, Rational, IBM, ClearCase training, CM, scm, ClearCase help, consulting, ClearQuest, BM Rational Tools consultant, trainer, training, ClearCase guru, configuration management"

How can I programmatically find the MVFS Drive in Windows?

This is often the question for new trigger writers or script writers. You know it is usually the "M drive" on most installations, but you do not want to rely on the convention (and rightly so in this case) as most shops still do not "control" the desktop (in windows ClearCase is always installed locally). Your dilemma is to reliably calculate the MVFS Drive to automate some process in a script or trigger.

The first and most important thing to remember is do not assume. One may be tempted in a trigger to use the ClearCase Environmental variable CLEARCASE_PN or CLEARCASE_XPN and then grab the start of the value, which might resemble:

M:\some_view\some_vob\some_dir\foo.c

Coding to this might work for the policy maker that is accustomed to working from under the MVFS drive, but a developer might have their view mapped to some drive (i.e. "J") and they may choose to work there where the ClearCase Environmental variable CLEARCASE_PN or CLEARCASE_XPN might resemble:

J:\ some_vob\some_dir\foo.c

So something a bit more robust and reliable should be used. One option is to use the output of the net use command:

Only one (1) line in the output will have a drive letter followed by a ':' followed by the pattern '\\view' followed by whitespace (one or more spaces or tabs) followed by the string "ClearCase Dynamic Views" ... the line that contains the MVFS drive (in the above example it is "M"). Here is some Perl code one might use to extract the driver letter.

-------- <snip> --------
@net_use = `net use`;
@mvfs_line = grep (/[ \t]+[A-Z]\:[ \t]+\\\\view[ \t]+ClearCase Dynamic Views/, @net_use);
($temp_data) = split (/\:/, $mvfs_line[0]);
$drive_letter = chop($temp_data);
-------- <snip> --------

Another option is to read the value directly from the Windows Registry by using the output of the regedit command.

-------- <snip> --------
@regedit = `regedit /e tfile "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Mvfs\\Parameters" & type tfile | findstr \"^\\"drive\\"=\\"\"`;
unlink("tfile");
@data = split (/\"/, $regedit[0]);
$drive_letter = $data[3];
-------- <snip> --------

In either case you can reliably get the MVFS drive letter without having to write much code. I have not found either one appreciably faster than the other so use either one to taste. Let us know if you find another way.

Hope this helps...