#!PECMD
ENVI^ ForceLocal=1

//ÓÃ·¨Ê¾Àý:
//SwapDrv D:  E:

_SUB SwapDrv
    SET &Drv1=%~1
    SET &Drv2=%~2
    GetDev "%Drv1%" &&Dev1
    GetDev "%Drv2%" &&Dev2
    FIND $[ '%Dev1%'='' | '%Dev2%'='' ], EXIT
    SUBJ *- %Drv1%
    SUBJ *- %Drv2%
    SUBJ *  %Drv1%,%Dev2%
    SUBJ *  %Drv2%,%Dev1%
_END

_SUB GetDev
    SET &Drv=%~1
    SET &nm=%~2
    SET &Dev=
    FIND $%Drv%<>,
    {*
        part -phy# list drv %Drv%,&&V
        FIND $%V%<>,
        {   MSTR  &&pt,&&hd=<1><10>%V%
            FIND $%pt%>0, SET Dev=\Device\Harddisk%hd%\Partition%pt%
        }!
        {   part -cdrom list drv %Drv%,&&V
            MSTR &&Id=<1>%V%
            FIND $%Id%<>, SET DEV=\\.\CDROM%Id%
        }
    }
    ENVI-ret %nm%=%Dev%
_END
