home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Security / Security.zip / se223441.zip / UNINSTAL.CMD < prev    next >
OS/2 REXX Batch file  |  1999-06-03  |  21KB  |  669 lines

  1. /* SecureEntry Release 3.x uninstaller routine   */
  2. /* (C) IBM Corp  1996,1998. All rights reserved  */
  3. /* Returns 0 -> all ok, 1 -> warnings 2->error   */
  4.  
  5. say 'IBM SecureEntry for OS/2 Version 3'
  6. say '5793-R46 (C) Copyright IBM Corp. 1996'
  7. say 'All Rights reserved. US Government Users Restricted Rights -'
  8. say 'Use, duplication or disclosure restricted by GSA ADP '
  9. say 'Schedule Contract with IBM Corp. '
  10. say 'Licensed Materials - Property of IBM.'
  11. say
  12.  
  13. If RxFuncQuery('SysLoadFuncs') Then
  14. Do
  15.   Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  16.   Call SysLoadFuncs
  17. End
  18.  
  19. parse arg command
  20.  
  21. batchparm=0
  22. shutdownparm=0
  23. do while command<>''
  24.   parse var command p1 command
  25.   if strip(translate(p1))='BATCH' then batchparm=1
  26.   else
  27.   if strip(translate(p1))='SHUTDOWN' then shutdownparm=1
  28.   else
  29.   do
  30.     say 'ERROR: Unknown parameter :'p1
  31.     return 2
  32.   end
  33. end
  34.  
  35.  
  36. /* 0. Verify Sentry is installed */
  37.  
  38. installpath = value('SGM_SHELL',,'OS2ENVIRONMENT')
  39. if installpath='' then
  40. do
  41.   say 'Error : SecureEntry not installed'
  42.   return 2
  43. end
  44.  
  45. sefilepath=installpath
  46. if substr(sefilepath,length(sefilepath),1)<>'\' then
  47.    sefilepath=sefilepath'\'
  48.  
  49.  
  50. parse upper value VALUE("PATH",,"OS2ENVIRONMENT") with ":\OS2\SYSTEM"-1 bootdrive+1
  51. ospath=value('PATH',,'OS2ENVIRONMENT')
  52. sesfilepath=bootdrive':\os2\security\sesdb\secure.sys'
  53. savesesfile=sefilepath'install\SECURE.SEN'
  54. oldstartupfile=bootdrive':\STARTUP.CMD'
  55. savestartupfile=sefilepath'install\STARTUP.SEN'
  56. configfile=bootdrive':\CONFIG.SYS'
  57. newconfigfile=bootdrive':\CONFIG.NEW'
  58. saveconfig=bootdrive':\CONFIG.SEN'
  59.  
  60. address cmd '@rxqueue /clear'                         /* Clear the Queue */
  61. address cmd '@Ver /R|rxqueue /fifo > nul'       /* Get OS/2 Revision Level */
  62. Do Queued()
  63.   Parse Pull linea
  64. End
  65. Parse var linea . revnumber               /* Just get the build level */
  66. revnumber=Strip(revnumber)
  67. vernumber=left(SysOS2Ver(),3)
  68.  
  69. ismerlin=0
  70. if (datatype(revnumber,'N')=1)&(datatype(vernumber,'N')=1) then
  71. do
  72.   if vernumber>2.3 then ismerlin=1
  73. end
  74.  
  75. if rxfuncquery('rxedyucm_getuser') then
  76. do
  77.   call rxfuncadd 'RxEdyUcmLoadFuncs', 'RXUCM','RxEdyUcmLoadFuncs'
  78.   call RxEdyUcmLoadFuncs
  79. end
  80.  
  81. isadmin=1
  82. if stream(sefilepath'install\SENTRY.SIG','c','query exists')<>'' then
  83. do
  84.   if rxfuncquery('rxedyucm_getuser')=0 then
  85.   do
  86.     gu=rxedyucm_getuser()
  87.     parse var gu other'ADMIN:'isadmin
  88.   end
  89. end
  90. if batchparm=0 then
  91. do
  92.   if isadmin=0 then
  93.   do
  94.     say 'ERROR: Administrator privilege required'
  95.     return 2
  96.   end
  97.   say 'SecureEntry deinstallation procedure'
  98.   say '===================================='
  99.   say 'WARNING : This process will completely remove SecureEntry from'
  100.   say 'this workstation. Do you want to proceed (yes/no) ?'
  101.   parse pull response
  102.   if abbrev('YES',translate(strip(response)),1) then
  103.   do
  104.     returncode=0
  105.   end
  106.   else
  107.   do
  108.     if abbrev('NO',translate(strip(response)),1)=0 then say 'NO assumed'
  109.     returncode=1
  110.     return returncode
  111.   end
  112. end
  113. else
  114. do
  115.   call RxEdyUcm_Enable_Remote 8
  116.   returncode=0
  117. end
  118.  
  119. if RxEdyUcm_Matches('?:\IBMLAN\RPL\BB??.??\SGMSHELL\',sefilepath)<>0 then
  120. do
  121.   /* look in sgmuserpath to see if wsod enabled right now. If yes, recreate the workstations folder. */
  122.   if stream(substr(sefilepath,1,13)'USER'substr(sefilepath,14)'NOUSER\EDYSLA.INI','c','query exists')<>'' then
  123.   do
  124.     say 'Disabling WSOD support'
  125.     address cmd '@'sefilepath'install\SEWSODEN.EXE DA DS 1>nul 2>&1'
  126.   end
  127. end
  128.  
  129. /* 0.5 Ensure launchpad erased   */
  130. restoredpad=0
  131. if ismerlin=1 then
  132. do
  133.   say 'Clearing warpcenter..'
  134.   /* Set Machine profile */
  135.   address cmd '@'sefilepath'exec\EDYSCTST.EXE 1>nul 2>&1'
  136.   restoredpad=1
  137. end
  138. if restoredpad=0 then
  139. do
  140.   say 'Clearing launchpad..'
  141.  
  142.   rc=sysfiledelete(sefilepath'nouser\EDYPAD.INI')
  143.   address cmd '@'sefilepath'exec\EDYLNREF.EXE /F 1>nul 2>&1'
  144.  
  145.   rc=SysMoveObject('<EDY_LP_BACKUP>', '<WP_DESKTOP>')
  146.   if rc=1 then
  147.   do
  148.     rc=SysSetObjectData('<EDY_LP_BACKUP>', 'OBJECTID=<WP_LAUNCHPAD>')
  149.     rc =SysIni('USER', 'PM_Workplace:Location', '<EDY_LP_BACKUP>', 'DELETE:')
  150.     restoredpad=2
  151.   end
  152. end
  153.  
  154. /* 1. Clear Workbench            */
  155. say 'Destroying workbench..'
  156. result=SysDestroyObject("<SGM_MAIN_WB>")
  157. if result<>1 then
  158. do
  159.   say 'Warning : Unable to destroy workbench folder.'
  160.   returncode=1
  161. end
  162. result=SysDestroyObject(sefilepath"TEMPLATE")
  163. if result<>1 then
  164. do
  165.   say 'Warning : Unable to destroy workbench folder.'
  166.   returncode=1
  167. end
  168.  
  169. /* 2. Deregister classes         */
  170. if stream(sefilepath'install\EDYCLASS.EXE','c','query exists')<>'' then
  171. do
  172.   say 'Deregistering classes..'
  173.   address cmd '@'sefilepath'install\EDYCLASS /U 1>nul 2>&1'
  174.   if rc<>0 then
  175.   do
  176.     say 'Warning : Deregistering classes ended up in error.'
  177.     returncode=1
  178.   end
  179. end
  180. else
  181. do
  182.   say 'Warning : Could not deregister classes (EDYCLASS not found).'
  183.   returncode=1
  184. end
  185.  
  186. /* 2.5 Crearing associations */
  187. say 'Clearing associations ...'
  188. associations.0=5
  189. associations.1='SE Launchpad Profile'
  190. associations.2='SE Treelock Profile'
  191. associations.3='SE Floppy Profile'
  192. associations.4='SE SES Profile'
  193. associations.5='SE Win Profile'
  194. MsgFile=sefilepath'EXEC\EDYERROR.MSG'
  195. do i=1 to associations.0
  196.   NewTitle = SysGetMessage(679+i, MsgFile)
  197.   If Abbrev(NewTitle, 'SYS0') then
  198.     NewTitle = ''
  199.   Else
  200.     NewTitle = substr(NewTitle, 1, length(NewTitle) - 2)
  201.   if newtitle<>'' then associations.i=newtitle
  202. end
  203.  
  204. do i=1 to associations.0
  205.   /* Create type */
  206.   type=associations.i
  207.   call sysini 'USER','PMWP_ASSOC_TYPE',type,'DELETE:'
  208. end
  209.  
  210.  
  211. /* 3. Deregister SYS_DLLs        */
  212. if stream(sefilepath'exec\EDYWINI.EXE','c','query exists')<>'' then
  213. do
  214.   say 'Deregistering SYS_DLLs..'
  215.   address cmd '@EDYWINI /U EDYLKSTR 1>nul 2>&1'
  216.   if rc<>0 then
  217.   do
  218.     say 'Warning : Could not deregister EDYLKSTR.'
  219.     returncode=1
  220.   end
  221.  
  222.   address cmd '@EDYWINI /U EDYSESNO 1>nul 2>&1'
  223.   if rc<>0 then
  224.   do
  225.     say 'Warning : Could not deregister EDYSESNO.'
  226.     returncode=1
  227.   end
  228.  
  229.   address cmd '@EDYWINI /U EDYWIN 1>nul 2>&1'
  230.   if rc<>0 then
  231.   do
  232.     say 'Warning : Could not deregister EDYWIN.'
  233.     returncode=1
  234.   end
  235. end
  236. else
  237. do
  238.   say 'Warning : Could not deregister SYS_DLLs (EDYWINI not found).'
  239.   returncode=1
  240. end
  241.  
  242. /* 4. Retouch SES file           */
  243. if stream(savesesfile,'c','query exists')<>'' then
  244. do
  245.   say 'Reseting SES file..'
  246.   address cmd '@copy 'savesesfile' 'sesfilepath' 1>nul 2>&1'
  247.   if rc<>0 then
  248.   do
  249.     say 'Warning : Could not copy old SES configuration file'
  250.     returncode=1
  251.   end
  252. end
  253.  
  254. /* 5. Retouch CONFIG.SYS         */
  255. say 'Reseting config.sys file'
  256.  
  257. address cmd '@copy 'configfile' 'saveconfig' 1>nul 2>&1'
  258. if rc<>0 then
  259. do
  260.   say 'Error : Could not backup CONFIG.SYS file as 'saveconfig
  261.   returncode=1
  262. end
  263. else
  264. do
  265.   rc=stream(configfile,'c','open read')
  266.   if rc<>'READY:' then
  267.   do
  268.     say 'Error : Could not open file 'configfile
  269.     returncode=1
  270.   end
  271.   else
  272.   do
  273.     i=0
  274.     do while lines(configfile)
  275.       i=i+1
  276.       filestem.i=linein(configfile)
  277.     end
  278.     rc=stream(configfile,'c','close')
  279.     filestem.0=i
  280.     call addconfig  0,'DEL','SET SGM_DB',''
  281.     call addconfig  0,'DEL','SET SGM_SHELL',''
  282.     call addconfig  0,'DEL','SET SGM_OVER_MK',''
  283.     call addconfig  0,'DEL','SET EDYEU',''
  284.     call addconfig  0,'DEL','SET SGM_LS',''
  285.     call addconfig  0,'DEL','SET SGM_UCM_ENABLE',''
  286.     call addconfig  0,'DEL','SET SGM_UCM_BRANCH',''
  287.     call addconfig  0,'DEL','SET SGM_UCM_THIS_BRANCH',''
  288.     call addconfig  0,'DEL','SET SGM_SL_LOGMODE',''
  289.     call addconfig  0,'DEL','SET SGM_SL_LOGPATH',''
  290.     call addconfig  0,'DEL','SET SGM_ADM_PRIV',''
  291.     call addconfig  0,'DEL','SET SGM_SES_LOGPATH',''
  292.     call addconfig  0,'DEL','SET SGM_INI_LOGPATH',''
  293.     call addconfig  0,'DEL','SET SGM_WPS_FASTLOAD',''
  294.     call addconfig  0,'DEL','SET SGM_WPS_LOADCLASS',''
  295.     call addconfig  0,'DEL','SET SGM_WPS_DISABLE',''
  296.     call addconfig  0,'DEL','SET SGM_WPS_PRINTJOBS',''
  297.     call addconfig  0,'DEL','SET SGM_WPS_NONDESKTOP',''
  298.     call addconfig  0,'DEL','SET SGM_WPS_TRACE',''
  299.     call addconfig  0,'DEL','SET SGM_WPS_BEEP',''
  300.     call addconfig  0,'DEL','SET SGM_WPS_SKIP_PREPOPULATE',''
  301.     call addconfig  0,'DEL','SET SGM_SES_CAD',''
  302.     call addconfig  0,'DEL','SET SGM_SES_INACTIVITY',''
  303.     call addconfig  0,'DEL','SET SGM_ALLOW_CAD',''
  304.     call addconfig  0,'DEL','SET SGM_EDYSC_DISABLE',''
  305.     call addconfig  0,'DEL','SET SGM_DISABLE_SYSTEM_KEYS',''
  306.     call addconfig  0,'DEL','SET SGM_HOOK_SYSTEM_KEYS',''
  307.     call addconfig  0,'DEL','SET SGM_EDYLK_SHOW',''
  308.     call addconfig  0,'DEL','SET SGM_BACK_BITMAP',''
  309.     call addconfig  0,'DEL','SET SGM_PM_WAIT_B4_KILL',''
  310.     call addconfig  0,'DEL','SET SGM_PM_WAIT_B4_FLUSH',''
  311.     call addconfig  0,'DEL','SET SGM_WIN_EXPLICITMENUS',''
  312.     call addconfig  0,'DEL','SET SGM_SS_IF_NO_AUTOLOCKUP',''
  313.     call addconfig  0,'DEL','SET SGM_SS_WHEN_LOCKUP',''
  314.     call addconfig  0,'DEL','SET SGM_SS_USEREXIT',''
  315.     call addconfig  0,'DEL','SET SGM_SS_ALLOW_IP',''
  316.     call addconfig  0,'DEL','SET SGM_SS_ALLOW_IU',''
  317.     call addconfig  0,'DEL','SET SGM_SHUTDOWN_AT_LOGON_PANEL',''
  318.     call addconfig  0,'DEL','SET SGM_LS_IFLOGGED',''
  319.     call addconfig  0,'DEL','SET SGM_SLA_EXEC',''
  320.     call addconfig  0,'DEL','SET SGM_SLA_TYPE',''
  321.     call addconfig  0,'DEL','SET SGM_HIDE_EXIT_AFTER_LOGON',''
  322.     call addconfig  0,'DEL','SET SGM_WPS_IGNORE_ADMIN',''
  323.     call addconfig  0,'DEL','SET SGM_REFRESH_PARMS',''
  324.     call addconfig  0,'DEL','SET SGM_NETBIOS_ADAPTER_NUM',''
  325.     call addconfig  0,'DEL','SET SGM_UCM_LOGPATH',''
  326.     call addconfig  0,'DEL','SET EDY_UCM_MAXROWS',''
  327.     call addconfig  0,'DEL','SET SGM_HIDE_WAIT_DLGS',''
  328.     call addconfig  0,'DEL','SET SGM_FORCE_LUALIAS',''
  329.     call addconfig  0,'DEL','SET SGM_FORCE_MODE',''
  330.     call addconfig  0,'DEL','SET SGM_UCM_DBDFT',''
  331.     call addconfig  0,'DEL','SET SGM_HOOK_CANN_KEY',''
  332.     call addconfig  0,'DEL','SET SGM_USER_DLGS',''
  333.     call addconfig  0,'DEL','SET SGM_ROAM_LOGPATH',''
  334.     call addconfig  0,'DEL','SET EDYLOADCLASS',''
  335.     call addconfig  0,'DEL','SET EDYOBJTRACE',''
  336.     call addconfig  0,'RDD','SET PATH',sefilepath'exec'
  337.     call addconfig  0,'RDD','SET PATH',sefilepath'wrkb'
  338.     call addconfig  0,'RDD','SET PATH',sefilepath'service'
  339.     call addconfig  0,'RDD','SET DPATH',sefilepath'exec'
  340.     call addconfig  0,'RDD','SET HELP',sefilepath'help'
  341.     call addconfig  0,'RDD','SET BOOKSHELF',sefilepath'install'
  342.     call addconfig  0,'RDD','LIBPATH',sefilepath'dll'
  343.     call addconfig  0,'RDD','LIBPATH',sefilepath'wrkb\dll'
  344.     call addconfig  0,'RDD','LIBPATH',bootdrive':\os2\security\ses'
  345.     call addconfig  0,'RDD','LIBPATH',bootdrive':\os2\security\sesdb'
  346.  
  347.     call addconfig  0,'DEL','SET RUNWORKPLACE',''
  348.     call addconfig  0,'DEL','SET RESTARTOBJECTS',''
  349.     call addconfig  0,'DEL','SET AUTOSTART',''
  350.     call addconfig  0,'DEL','PROTSHELL',''
  351.  
  352.     call addconfig  0,'DEL','DEVICE',sefilepath'EXEC\EDYCAD.SYS'
  353.     call addconfig  0,'DEL','BASEDEV','SESDD32.SYS'
  354.     call addconfig  0,'DEL','BASEDEV','EDYDD32.SYS'
  355.     call addconfig  0,'DEL','BASEDEV','EDYFLPY.FLT'
  356.  
  357.     call addconfig  0,'DEL','CALL',bootdrive':\OS2\SECURITY\SES\SESSTART.EXE 'bootdrive':\OS2\SECURITY\SES\SESDMON.EXE'
  358.     call addconfig  0,'DEL','CALL',sefilepath'exec\edylogfs.exe'
  359.     call addconfig  0,'DEL','SET SESDBPATH',''
  360.     call addconfig  0,'DEL','SET AUTOGUEST',''
  361.     call addconfig  0,'DEL','SET GUESTNAME',''
  362.     call addconfig  0,'DEL','SET TRUSTEDPATH',''
  363.     call addconfig  0,'DEL','SET USERSHELL',''
  364.     call addconfig  0,'DEL','SET RESTARTUSERSHELL',''
  365.     call addconfig  0,'DEL','SET BACKGROUNDBITMAP',''
  366.     call addconfig  0,'DEL','SET TEMP',sefilepath'TEMP'
  367.     call addconfig  0,'DEL','SET TMP',sefilepath'TEMP'
  368.  
  369.     call addconfig 1,'SET','PROTSHELL',bootdrive':\OS2\PMSHELL.EXE'
  370.     call addconfig 2,'SET','SET RUNWORKPLACE',bootdrive':\OS2\PMSHELL.EXE'
  371.  
  372.     if restoredpad=1 then
  373.     do
  374.       call addconfig 3,'SET','SET AUTOSTART','PROGRAMS,TASKLIST,FOLDERS,WARPCENTER'
  375.     end
  376.     else
  377.     do
  378.       call addconfig 3,'SET','SET AUTOSTART','PROGRAMS,TASKLIST,FOLDERS,LAUNCHPAD'
  379.     end
  380.  
  381.     sourcedeldir=sefilepath'INSTALL\EDYDD.EXE'
  382.     if stream(sourcedeldir,'c','query exists')='' then
  383.     do
  384.       parse source p1 p2 thisfile
  385.       sourcedeldir=filespec('drive',thisfile)||filespec('path',thisfile)||'EDYDD.EXE'
  386.     end
  387.     address cmd '@COPY 'sourcedeldir' 'bootdrive':\EDYDD.EXE >nul'
  388.     newerror=0
  389.     rc=sysfiledelete(newconfigfile)
  390.     rc=stream(newconfigfile,'c','open write')
  391.     if rc<>'READY:' then
  392.     do
  393.       say 'Error : Could not recreate file 'newconfigfile
  394.       newerror=1
  395.       returncode=1
  396.     end
  397.     else
  398.     do
  399.       do j=1 to filestem.0
  400.         rc=lineout(newconfigfile,filestem.j)
  401.         if rc<>0 then
  402.         do
  403.           say 'Error : Could not write to file 'newconfigfile
  404.           newerror=1
  405.           returncode=1
  406.         end
  407.       end
  408.       rc=stream(newconfigfile,'c','close')
  409.       if newerror=0 then
  410.       do
  411.         rc=sysfiledelete(configfile)
  412.         rc=stream(configfile,'c','open write')
  413.         if rc<>'READY:' then
  414.         do
  415.           say 'Error : Could not recreate file 'configfile
  416.           address cmd '@copy 'saveconfig' 'configfile' 1>nul 2>&1'
  417.           returncode=1
  418.         end
  419.         else
  420.         do
  421.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @echo Completing SecureEntry Uninstall. Please wait...')
  422.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @'bootdrive':\EDYDD.EXE 'sefilepath' /n >nul')
  423.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\EDYDD.EXE >nul')
  424.           if stream(bootdrive':\EDYSTART.CMD','c','query exists')<>'' then
  425.             rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\EDYSTART.CMD >nul')
  426.           if stream(bootdrive':\EDYLKINI.LOG','c','query exists')<>'' then
  427.             rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\EDYLKINI.LOG >nul')
  428.           if stream(bootdrive':\OS2\SECURITY\SESDB\EDYSLA.LOG','c','query exists')<>'' then
  429.             rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\OS2\SECURITY\SESDB\EDYSLA.LOG >nul')
  430.           if stream(bootdrive':\OS2\BOOT\EDYDD32.SYS','c','query exists')<>'' then
  431.             rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\OS2\BOOT\EDYDD32.SYS >nul')
  432.           if stream(bootdrive':\OS2\BOOT\EDYFLPY.FLT','c','query exists')<>'' then
  433.             rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'bootdrive':\OS2\BOOT\EDYFLPY.FLT >nul')
  434.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @COPY 'newconfigfile' 'configfile' >nul')
  435.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'newconfigfile' >nul')
  436.           rc=lineout(configfile,'CALL='bootdrive':\OS2\CMD.EXE /C @DEL 'saveconfig' >nul')
  437.           do j=1 to filestem.0
  438.             rc=lineout(configfile,filestem.j)
  439.             if rc<>0 then
  440.             do
  441.               say 'Error : Could not write to file 'configfile
  442.               address cmd '@copy 'saveconfig' 'configfile' 1>nul 2>&1'
  443.               returncode=1
  444.             end
  445.           end
  446.           rc=stream(configfile,'c','close')
  447.         end
  448.       end
  449.     end
  450.   end
  451. end
  452.  
  453. /* 6. Remigrate edystart.cmd     */
  454. if stream(savestartupfile,'c','query exists')<>'' then
  455. do
  456.   say 'Reseting startup file..'
  457.   address cmd '@copy 'savestartupfile' 'oldstartupfile' 1>nul 2>&1'
  458.   if rc<>0 then
  459.   do
  460.     say 'Warning : Could not copy old STARTUP.CMD file'
  461.     returncode=1
  462.   end
  463. end
  464.  
  465. /* At this point, only EXEC and DLL dirs are alive */
  466. if (batchparm=0)&(shutdownparm=0) then
  467. do
  468.   say 'SecureEntry deinstall first process completed.'
  469.   say 'NOTE:'
  470.   say '- The SecureEntry config.sys file has been copied as 'saveconfig
  471.   say '- The files 'configfile' and 'newconfigfile' are required to complete'
  472.   say '  deinstallation after boot'
  473.   say '- The file 'sefilepath'install\CONFIG.SEN contains the config.sys file'
  474.   say '  that existed before the SecureEntry installation'
  475.   say 'You can review the different configuration files and touch the 'newconfigfile
  476.   say 'file before reboot. This file will be used as the new config.sys file after'
  477.   say 'the following boot.'
  478.   say 'You can shutdown now the system and reboot to complete the process.'
  479.   say 'Do you want to shutdown now (yes/no) ?'
  480.   parse pull response
  481.   if abbrev('YES',translate(strip(response)),1) then
  482.   do
  483.     address cmd 'start shutdown.exe'
  484.   end
  485.   else
  486.   do
  487.     if abbrev('NO',translate(strip(response)),1)=0 then say 'NO assumed'
  488.   end
  489. end
  490. else
  491. do
  492.   if (batchparm=1) then
  493.     call RxEdyUcm_Enable_Remote 9
  494.   if shutdownparm=1 then
  495.     address cmd 'start shutdown.exe'
  496. end
  497.  
  498. return returncode
  499.  
  500. addconfig:
  501.  
  502. parse arg order,command,token,value
  503. value=strip(value)
  504. token=strip(token)
  505.  
  506. if (command='SET')|(command='SEF') then
  507. do
  508.   /* SET command means insert SET token=value to the end of config */
  509.   /* erasing previous value                                        */
  510.   /* The SEF command does the same but only searches an replaces   */
  511.   /* full matching specs                                           */
  512.   /* -1 => to the end. 0=> to the beginning n=> at line position n */
  513.   /* in any case, if the token was found, just substitute it       */
  514.  
  515.   valueset=0
  516.   j=words(token)
  517.   do i=1 to filestem.0
  518.     parse var filestem.i thetoken'='thevalue
  519.     found=1
  520.     do k=1 to j
  521.       if translate(word(token,k))<>translate(word(thetoken,k)) then
  522.       do
  523.         found=0
  524.         leave
  525.       end
  526.     end
  527.     if found=1 then
  528.     do
  529.       if (command='SET')|(translate(substr(strip(thevalue),1,length(value)))=translate(value)) then
  530.       do
  531.         if (valueset=0) then
  532.         do
  533.           filestem.i=token'='value
  534.           valueset=1
  535.         end
  536.         else
  537.         do
  538.           /* here delete the line */
  539.           do k=i+1 to filestem.0
  540.             z=k-1
  541.             filestem.z=filestem.k
  542.           end
  543.           filestem.0= (filestem.0)-1
  544.         end
  545.       end
  546.     end
  547.   end
  548.   if valueset=0 then
  549.   do
  550.     i=order
  551.     if order=0  then i=1
  552.     if order=-1 then i=1+filestem.0
  553.     if i>1+filestem.0 then i=1+filestem.0
  554.     if filestem.0>i then
  555.     do
  556.       do k=filestem.0 to i by -1
  557.         z=k+1
  558.         filestem.z=filestem.k
  559.       end
  560.     end
  561.     filestem.i=token'='value
  562.     filestem.0=1+filestem.0
  563.   end
  564. end
  565. else
  566. if (command='FND')|(command='FNF') then
  567. do
  568.   j=words(token)
  569.   do i=1 to filestem.0
  570.     parse var filestem.i thetoken'='thevalue
  571.     found=1
  572.     do k=1 to j
  573.       if translate(word(token,k))<>translate(word(thetoken,k)) then
  574.       do
  575.         found=0
  576.         leave
  577.       end
  578.     end
  579.     if found=1 then
  580.     do
  581.       if (command='FND')|(translate(substr(strip(thevalue),1,length(value)))=translate(value)) then
  582.          return i
  583.     end
  584.   end
  585.   return 0
  586. end
  587. if command='DEL' then
  588. do
  589.   j=words(token)
  590.   do i=1 to filestem.0
  591.     parse var filestem.i thetoken'='thevalue
  592.     found=1
  593.     do k=1 to j
  594.       if translate(word(token,k))<>translate(word(thetoken,k)) then
  595.       do
  596.         found=0
  597.         leave
  598.       end
  599.     end
  600.     if found=1 then
  601.     do
  602.       if (value='')|(translate(substr(strip(thevalue),1,length(value)))=translate(value)) then
  603.       do
  604.         /* here delete the line */
  605.         do k=i+1 to filestem.0
  606.           z=k-1
  607.           filestem.z=filestem.k
  608.         end
  609.         filestem.0= (filestem.0)-1
  610.       end
  611.     end
  612.   end
  613. end
  614. else
  615. if (command='ADD')|(command='RDD') then
  616. do
  617.   j=words(token)
  618.   do i=1 to filestem.0
  619.     parse var filestem.i thetoken'='thevalue
  620.     found=1
  621.     do k=1 to j
  622.       if translate(word(token,k))<>translate(word(thetoken,k)) then
  623.       do
  624.         found=0
  625.         leave
  626.       end
  627.     end
  628.     if found=1 then
  629.     do
  630.       parsedstring=''
  631.       parse var thevalue temp';'other
  632.       found=0
  633.       do while temp<>''
  634.         if translate(value)=translate(temp) then
  635.         do
  636.           if command='RDD' then
  637.           do
  638.             if parsedstring='' then
  639.               filestem.i=thetoken'='other
  640.             else
  641.               filestem.i=thetoken'='parsedstring';'other
  642.             found=1
  643.             leave
  644.           end
  645.           else
  646.           do
  647.             found=1
  648.             leave
  649.           end
  650.         end
  651.         if parsedstring='' then parsedstring=temp
  652.         else
  653.            parsedstring=parsedstring';'temp
  654.         parse var other temp';'other
  655.       end
  656.       if (found=0)&(command='ADD') then
  657.       do
  658.         if substr(thevalue,length(thevalue),1)=';' then thevalue=thevalue||value
  659.         else
  660.           thevalue=thevalue';'value
  661.         filestem.i=thetoken'='thevalue
  662.       end
  663.       leave
  664.     end
  665.   end
  666. end
  667. return
  668. 
  669.