home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 375.lha / ArexxExamples / bootck.rexx < prev    next >
OS/2 REXX Batch file  |  1990-05-02  |  4KB  |  133 lines

  1. /* bootck.rexx Checks floppies for viruses and saves a irregular block */
  2. no_boot = 'No bootblock installed'
  3. real_boot = 'ARP thinks OK bootblock' /* this is arp's msg on OK bootblock */
  4. /* if you use the CBM install program you must change the above string
  5.    to reflect the CBM message
  6.    You will also have to change the name of the disk/dir you want your
  7.    non-standard boot blocks saved to
  8. */
  9. YES   = 1
  10. NO    = 0
  11. STARTUP_SEQ = NO
  12. SAVE        = 0
  13. BOOT        = 1
  14. NOBOOT      = 2
  15. WriteProtect = TRUE              /* I disk write protect status */
  16.  
  17. arg vol                          /* gotta enter a volume name */
  18. vol = upper(vol)
  19.  
  20. if length(vol) < 4 then do
  21.     say "  You GOTTA Enter A Disk to check !!"
  22.     exit
  23.     end
  24.  
  25. select
  26.     when compare(vol,'DF0:') = 0 then call fixit
  27.     when compare(vol,'DF1:') = 0 then call fixit
  28.     /* if you have df2: and df3: un - comment the below */
  29.     /* when compare(vol,'DF2:') = 0 then call fixit */
  30.     /* when compare(vol,'DF3:') = 0 then call fixit */
  31.     otherwise say 'Drive Name Entry Error'
  32.     end
  33. exit
  34.  
  35.  
  36.                 /* CHECK FOR NON STANDARD BOOT BLOCK */
  37. ""'install 'vol 'check | execio  for 1 var boot_ck'
  38.  
  39.                 /* CHECK FOR EXISTENCE OF STARTUP-SEQUENCE */
  40. if exists(vol's/startup-sequence') then STARTUP_SEQ = YES
  41.  
  42. /* * * * * * * * * * STARTUP-SEQUENCE NOT FOUND ON DISK * * * * * * * * * */
  43. if STARTUP_SEQ == NO then do
  44.     if compare(boot_ck,no_boot) == 0 then do             /* no boot block */
  45.         say 'no startup-sequence,no boot block'
  46.         exit
  47.         end
  48.  
  49.     if compare(boot_ck,real_boot) ~= 0 then do       /* boot non standard */
  50.         say 'there is NO startup-sequence BUT'
  51.         say 'There is a Non-Standard Boot Block'
  52.         call yes_no 'DE-Install 'vol '?'
  53.         if result == YES then call install_disk NOBOOT  /* DE-INSTALL   ? */
  54.         else say "Okay but it might Be A Virus !!"
  55.         exit
  56.         end
  57.  
  58.     else if compare(boot_ck,real_boot) == 0 then do
  59.         say 'there is NO startup-sequence BUT'
  60.         say 'there is a VALID Boot block'               /* DE-INSTALL   ? */
  61.         call yes_no 'De-Install 'vol '?'
  62.         if result == YES then call install_disk NOBOOT
  63.         exit
  64.         end
  65.     end
  66.  
  67. /* * * * * * * * * *  STARTUP-SEQUENCE LOCATED ON DISK * * * * * * * * * */
  68. if STARTUP_SEQ == YES then do
  69.     if compare(boot_ck,no_boot) == 0 then do            /* no boot block */
  70.         say 'there is a startup-sequence on this disk'
  71.         say 'but No boot block is installed'
  72.         call yes_no 'Install Boot Block on 'vol '?'
  73.         if result = YES then call install_disk BOOT
  74.         end
  75.  
  76.     else if compare(boot_ck,real_boot) ~= 0 then do /* boot non standard */
  77.         say 'there is a startup-sequence BUT'
  78.         say 'Boot Block is non-standard '
  79.         call yes_no 'Install standard Boot Block on 'vol '?'
  80.         if result = YES then call install_disk SAVE    /* save non std ? */
  81.         else say "Ok but it might be a VIRUS .."
  82.         end
  83.  
  84.     end                                                 /* end seq = yes */
  85.  
  86.  
  87. install_disk:
  88. arg bt
  89.  
  90. /* check for a write protected disk */
  91. ""'info 'vol' | execio from 4 for 1 var diskinfo'    /* get info on disk */
  92. if compare(word(diskinfo,7),'Read') == 0 then do
  93.     say 'Disk is write protected !!'
  94.     exit
  95.     end
  96.                 /* DE_INSTALL DISK */
  97. if bt == NOBOOT = 1 then do forever
  98.     ""'install 'vol 'noboot'
  99.     ""'install 'vol 'check | execio  for 1 var boot_ck' /* re-check the disk */
  100.     if compare(boot_ck,no_boot) == 0 then do
  101.         say "NOW UN-BOOTABLE"
  102.         return
  103.         end
  104.      else do
  105.         call yes_no "CAN'T UN-INSTALL THIS DISK !!..Retry ?"
  106.         if result = NO then return
  107.         end
  108.     end
  109.  
  110. if bt == SAVE then do                       /* save non-std */
  111.     call gdname vol
  112.     x = '"' || getclip('DNAME') || '"'
  113.     say 'saving bootblock to dh1:new/'diskname
  114.     ""'bootback 'vol' dh1:new/'diskname
  115.     ""'filenote dh1:new/'diskname 'bootblock'
  116.     end
  117.  
  118.                     /* INSTALL GOOD BOOT BLOCK */
  119. do forever
  120.     ""'install 'vol                                     /* install disk */
  121.     ""'install 'vol 'check | execio  for 1 var boot_ck'
  122.     if compare(boot_ck,real_boot) == 0 then do
  123.         say "Boot Block is now Correct "
  124.         return
  125.         end
  126.  
  127.     else do         /* could not correct bad boot block */
  128.         call yes_no "Error Installing this disk.. RETRY ?"
  129.         if result = NO then return
  130.         end
  131.     end
  132.  
  133.