Home | OS/2 Software | Rexx | Get Boot Drive

Get Boot Drive

Contributed by: Chuck McKinnis

GetBootDrive trys the simple and then complex methods of determining your current boot drive. You can either store it as getbootdrive.cmd in a library in your path or include it in your code after uncommenting the "GetBootDrive: Procedure" statement.


 


/*
GetBootDrive
   Use SysBootDrive (RexxUtils) if it is available, use RxBootDrive
   (RxExtras) if it is available, or use an alternate method to get the
   value if neither is available.  Uncomment following if GetBootDrive
   is imbedded in a routine.
*/
/* GetBootDrive: Procedure */
If \Rxfuncquery('SysBootDrive') Then
   bootdrive = SysBootDrive()       /* Object or Updated Classic Rexx */
Else
   Do
      If \Rxfuncquery('RxBootDrive') Then
         bootdrive = RxBootDrive()                        /* RxExtras */
      Else
         Do                       /* Examine various config.sys items */
            Parse Upper Value Value('PATH', ,'OS2ENVIRONMENT') ,
               With ':\OS2\SYSTEM' - 1 bootdrive + 2
            If bootdrive = '' Then
               bootdrive = ,
               Substr(Value('RUNWORKPLACE', ,'OS2ENVIRONMENT'), 1, 2 )
            If bootdrive = '' Then
               bootdrive = ,
               Substr(Value('COMSPEC', ,'OS2ENVIRONMENT'), 1, 2)
            If bootdrive = '' Then
               bootdrive = ,
               Substr(Value('OS2_SHELL', ,'OS2ENVIRONMENT'), 1, 2)
            If bootdrive = '' Then
               bootdrive = ,
               Substr(Value('SYSTEM_INI', ,'OS2ENVIRONMENT'), 1, 2)
            If bootdrive = '' Then
               bootdrive = ,
               Substr(Value('USER_INI', ,'OS2ENVIRONMENT'), 1, 2)
            If bootdrive = '' Then                      /* no guesses */
               bootdrive = 0
         End
   End
Return bootdrive               /* Returns BootDrive, letter and colon */