[K12OSN] Way off topic - Windows batch file question

Michael E. Jaggers mej at mindspring.com
Fri Jul 8 16:23:25 UTC 2005


In <007301c583c6$d6c62400$b39b060a at winonacotter.org>, on 07/08/05 
   at 09:10 AM, "Jim Kronebusch" <jim at winonacotter.org> said:

>Sorry for the nature of this post, but I think there are Windows wizards
>out here as well.

>I have a Win2000 server and a pair of Iomega 160GB usb hard drives.  I
>need to back up to these drives.  I can set whatever backup program to
>back up to drive x:.  I need to be able to swap these drives weekly and
>take one off site.  Problem is when I plug in one drive it assigns drive
>h: to it, the other gets i: assigned to it.  This causes my backup
>program to get stupid.

>I am thinking I can solve this by placing a simple batch file in the
>Windows scheduler that deletes drive x:, runs a quick check for which
>drive is available h: or i:, then has an if statement duplicate h: to x:
>if h: exists, if h: doesn't exist and i: does exist the duplicate i: to
>x:.

>Does this make any sense?  This just seems like it could save a lot of
>money on tape drives if it is figured out.

Use the subst command:

   @echo off
   rem  Delete previous drive x substitution
   subst x: /d
   if not exist h:\nul goto no_h
   rem  Map the root of h as our new drive x
   subst x: h:
   goto doit
   :no_h
   if not exist i:\nul goto die
   rem  Map the root of i as our new drive x
   subst x: i:
   goto doit
   :doit
   rem
   rem  Now x is your drive...
   rem
   goto done
   :die
   echo Whoops!
   :done
   exit

-- 
-----------------------------------------------------------
"Michael E. Jaggers" <mej at mindspring.com>
-----------------------------------------------------------




More information about the K12OSN mailing list