Virtual Drives

I had this “virtual drive” script I wrote setup a while back for my windows machine to make certain things easier.  For instance I setup my apache htdocs directory so that it was the “W” drive so I could just open my computer and W and I would be there with my websites – it just made things more easily accessible.

The solution was used again for a different purpose when one day I had a friend who had installed windows and something went wrong.  A drive other than his main windows partition was set as “C” and his windows partition was created as “F”.  What made this a problem was that when he would install some programs (flash for example) it would attempt to install certain things to the registry on the “C” drive which it couldn’t find and there seemed to be no way to correct this.  So I showed him my little trick.  I didn’t think much of it until the other day he asked me for the script again because when he just installed his new computer the USB drive was “C” and he messed it up again.  He said he searched for a fix on Google and couldn’t find one.  You can’t just rename the partition because you are using it.  I imagine there is some kind of a fix if you put in a live cd and you can change it but we didn’t really look into it.  I just gave him the script and off he went.

So its a very simple batch script and you can modify it to do either of the things that I just mentioned.  Just save the following as virtualDrive.bat (or whateverYouWant.bat)

This first one shows my setting up the W drive:

@ECHO OFF
ECHO.

subst W: /d
subst W: D:htdocs
CLS
EXIT

This one shows the fix if your windows partition is not set to C and it is causing you a problem:

@ECHO OFF
ECHO.

subst C: /d
subst C: F:

CLS
EXIT

The first “subst” line deletes the “C” drive in case your script has already ran previously (this stops an error from popping up if it already exists) – The second creates the “C” drive pointing to the “F” drive.

The last hint is that if you want to have it created every time you start your computer, just put a link to the virtualDrive.bat file in your startup folder in the start menu.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *