home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / netdrv.zip / NETDRV.CMD next >
OS/2 REXX Batch file  |  1994-07-01  |  4KB  |  119 lines

  1. /* REXX procedure to toggle Network drivers in config.sys      */
  2. /* Rufan Redi Productions - (c) 1994 Version 1.0               */
  3.  
  4. /* Please backup your CONFIG.SYS before running this -
  5.    just in case ! Also, have a boot disk handy !
  6.    Please take note of the comment about the manual editing of
  7.    your CONFIG.SYS before running this                         */
  8.  
  9. /* Comments to Jeremy E Cath CI$- 100315,521
  10.    Donations to enable the work to continue via SnailMail to
  11.     Stoke Cottage, Marsh Lane, Maidenhead, Berks SL6 0DF. UK   */
  12.  
  13. /* Requires VREXX.EXE, VREXX.DLL, DEVBASE.DLL
  14.    to be present to display messages                           */
  15. /* Requires GetBootDrv.DLL to locate boot drive                */
  16. /* The program should be run ICONised                          */
  17.  
  18. /* In C:\CONFIG.SYS put the following two rem lines
  19.                - CASE SENSITIVE !
  20. rem ***NetworkStart
  21. .
  22. .  Network, or other drivers, device and run statements
  23. .
  24. rem ***NetworkEnd
  25.    to control the blocks of lines which will be toggled.       */
  26.  
  27. '@echo off'
  28.  
  29. title = 'NetDrv 1.0 - a Rufan Redi Production'
  30.  
  31. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  32. initcode = VInit()
  33. if initcode = 'ERROR' then signal CLEANUP
  34.  
  35. signal on failure name CLEANUP
  36. signal on halt name CLEANUP
  37. signal on syntax name CLEANUP
  38.  
  39. if arg(1) = 'YES' or arg(1) = 'NO' then
  40.   whatsup = arg(1)
  41. else
  42.   DO
  43.     msg.0 = 1
  44.     msg.1 = 'Do you want the Network drivers to be activated ?'
  45.     call VDialogPos 50,50
  46.     whatsup = VMsgBox(title, msg, 6)
  47.   END
  48.  
  49. if 0 < RxFuncQuery('SysLoadFuncs') THEN DO;
  50.   Call rxfuncadd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs';
  51.   Call SysLoadFuncs;
  52. END;
  53.  
  54. Call rxfuncadd 'GetBootDrive','GBOOTDRV','GetBootDrive';
  55. BootDrive=GetBootDrive();
  56. Config = BootDrive':\config.sys'
  57. TempFile = SysTempFileName('config.???')
  58.  
  59. Position.left = 20
  60. Position.bottom = 50
  61. Position.right = 80
  62. Position.top = 60
  63. Win = VOpenWindow(title, 'CYAN', position)
  64. Call VSay Win, 70, 400, 'Please wait... Updating' config'.'
  65.  
  66. rc = lineout(TempFile,,1)
  67.  
  68. if whatsup = 'YES' then
  69.   DO
  70.     DO WHILE LINES(config) <> 0
  71.       PARSE VALUE LINEIN(config) WITH first second rest
  72.       if second = '*n*' then
  73.         rc = lineout(TempFile, Space(rest))
  74.       else
  75.         rc = lineout(TempFile, Space(Space(first) Space(second) Space(rest)))
  76.     end /* do */
  77.     msg.1 = config 'now has the Network drivers active.'
  78.   END
  79. ELSE
  80.   DO
  81.     DO WHILE LINES(config) <> 0
  82.       PARSE VALUE LINEIN(config) WITH first second rest
  83.       rc = lineout(TempFile,Space(Space(first) Space(second) Space(rest)))
  84.       if second = '***NetworkStart' then
  85.       DO
  86.         parse value LineIn(config) with first second rest
  87.         do while second <> '***NetworkEnd'
  88.           if second <> '*n*' then
  89.             rc = lineout(TempFile,'rem *n*' Space(Space(first) Space(second) Space(rest)))
  90.           else
  91.             rc = lineout(TempFile,Space(Space(first) Space(second) Space(rest)))
  92.           parse value LineIn(config) with first second rest
  93.         end
  94.         if second = '***NetworkEnd' then
  95.           rc = lineout(TempFile,Space(Space(first) Space(second) Space(rest)))
  96.       end
  97.     end /* do */
  98.     msg.1 = config 'now has the Network drivers commented out.'
  99.   end
  100. /* EndIf */
  101. rc = stream(config,'c','close')
  102. rc = stream(TempFile,'c','close')
  103. copy TempFile config
  104. rc = SysFileDelete(TempFile)
  105.  
  106. msg.0 = 3
  107. msg.2 = ''
  108. msg.3 = 'You will need to reboot your machine for these changes to be activated.'
  109.  
  110. call VCloseWindow Win
  111. call VDialogPos 50, 50
  112. rb = VMsgBox(title, msg, 1)
  113.  
  114. CLEANUP:
  115.  call VExit
  116.  Call RxFuncDrop 'GetBootDrive'
  117.  
  118. EXIT;
  119.