Tuesday, April 10, 2007

Windows Vista and virtual drives using SUBST

There is still one DOS command I'm using every day even we now have Vista: SUBST. SUBST allows you to define a "virtual drive" likes this:

subst P: "C:\Users\TeX HeX\Documents"

After this command, you will have a new P: drive in your explorer that displays the contents of C:\Users\TeX HeX\Documents. This is quite useful if you need to develop something that will later run in a network and must use absolute paths.

With Vista, however there are two glitches with this. Number one, drives that you created without having an elevated context (No UAC prompt) will not be visible once you have elevated using UAC. For example, I always start Visual Studio with "Launch as Administrator" and thus didn't saw the P: drive.

Since I needed this drive in Visual Studio only, the solution was easy: Create a batch that includes the SUBST command, create a shortcut to this batch and edit the shortcut (Right click – Properties) to always launch as Administrator.

The Batch is a complete no-brainer:

subst P: "C:\Users\TeX HeX\Documents"

c:

cd "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"

start "" "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

That way I also do not forget to select "Run as Administrator" but get the UAC prompt directly.

No comments:

Post a Comment