home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
CLNINI.ZIP
/
CLEANINI.CMD
next >
Wrap
OS/2 REXX Batch file
|
1992-11-10
|
5KB
|
145 lines
/* CLEANINI.CMD - Version 1.1 - November 10, 1992
Copyright (C) 1992 by James D. Stuyck
This is "shareware" and, if you find it useful, please send a
contribution of $10.00 to:
J. D. Stuyck and Associates
6 Lincolnshire Circle
Bedford, TX 76021-4618
Tested and "seems to work just fine" with the ServicePak (XR06055)
installed. However, though the risk seems to be negligible, the
author specifically disclaims any responsibility for bad effects
arising from the use of this program.
PLEASE! -- Test this in your own environment before doing things
like arbitrarily discarding working OS2.INI and OS2SYS.INI files.
*/
If arg(1) = '?' | arg(1) = "help" then Signal Help /* Display some help */
Call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
If RxFuncQuery('SysLoadFuncs') then
Do
Say 'Error! The RexxUtil "SysLoadFuncs" problem.'
Say 'CLEANINI cannot continue!'
Exit
End
Call SysLoadFuncs
Parse upper arg Oldfile Newfile . /* Separate input values from arg*/
If Oldfile == '' then /* For no arg(s) assume OS2*.INI */
Do
Call CopyIni 'USER', 'OS2.NEW' /* Clean up OS2.INI */
Call CopyIni 'SYSTEM', 'OS2SYS.NEW' /* Clean up OS2SYS.INI */
Exit /* End the program */
End
If Oldfile == Newfile then /* Careful not to copy over self */
Do
Say 'Error! You cannot copy a file over itself.'
Say 'CLEANINI cannot continue!'
Exit /* End the program */
End
'@ECHO OFF'
'DIR' Oldfile '>NUL' /* Make sure file exists */
If rc \= 0 then
Do
Say Oldfile 'does not seem to exist.'
Say 'Please check your spelling.'
Say 'CLEANINI cannot continue!'
Exit /* End the program */
End
If Newfile == '' then /* Named file; test for new name */
Do
Parse value Oldfile with Newfile '.' junk
Newfile = Newfile||'.NEW'
End
Call CopyIni Oldfile, Newfile /* Clean up named INI file */
Exit /* End the program */
CopyIni: PROCEDURE /* Routine to do the real work */
Parse arg Oldfile, Newfile
Say 'Processing' Oldfile '---->' Newfile
Call SysFileDelete Newfile /* Erase copy of new file, if any*/
/* Much of the following was "cut" from the "OS/2 Procedures Language 2/REXX"
(REXX Information) on-line documentation found in the OS/2 2.0 Information
folder. The reader can expand "REXX Utiltiy Functions (RexxUtil)" then
read the part about "SysIni" for complete details.
*/
Call SysIni Oldfile, 'All:', 'Apps.'
If Result == 'ERROR:' then
Do
Say 'Error! ' Oldfile 'does not seem to be a valid .INI file.'
Say 'CLEANINI cannot continue!'
Exit
End
Else
Do i = 1 to Apps.0
Call SysIni Oldfile, Apps.i, 'All:', 'Keys.'
If Result == 'ERROR:' then
Do
Say 'Error! REXX SysIni function cannot process' Apps.i 'in' OldFile
Say "You may have a corrupted .INI file (which ain't too good)."
Say 'CLEANINI cannot continue!'
Exit
End
Else
Say 'Processing entry' i 'of' Apps.0 '('Apps.i'). It has' Keys.0 'keys.'
Do j=1 to Keys.0
val = SysIni(Oldfile, Apps.i, Keys.j)
Call SysIni Newfile, Apps.i, Keys.j, val
If Result == "ERROR:" then
Do
Say 'Error! REXX SysIni function cannot create' Apps.i Keys.j 'in' NewFile
Say 'Check to see if the disk is full.'
Say 'CLEANINI cannot continue!'
Exit
End
End
End
Say Newfile 'created successfully from' Oldfile
Return
Help:
Call SysCls
Say 'Usage: cleanini [OldFileName [NewFileName]]'
Say ' '
Say 'By default, with no optional parameters specified, the two critical OS/2 2.0'
Say '".INI" files are located (they are in the "\OS2" directory of your boot disk),'
Say 'cleaned (compressed), copied to the "current directory" and renamed:'
Say ' '
Say ' OS2.INI becomes OS2.NEW and OS2SYS.INI becomes OS2SYS.NEW.'
Say ' '
Say 'Often, you will find that the cleaned (NEW) files are somewhat smaller than the'
Say 'old files. You could then boot from the OS/2 installation diskettes and copy'
Say 'the NEW files to the \OS2 directory, renaming them with the INI extension.'
Say ' '
Say 'The old (input) file is NEVER modified.'
Say ' '
Say 'Other applications that use OS/2-style INI files can have their INI files'
Say 'cleaned. If an OldFileName is specified, it must be fully qualified. Examples:'
Say ' '
Say ' C:\OS2\EPM.INI or C:\OS2\APPS\KLONDIKE.INI or D:\OS2\APPS\OS2CHESS.INI'
Say ' '
Say 'NewFileName is optional. If it is not specified, then a new file is placed in'
Say 'the same directory with the same file name as the old file, with the file'
Say 'extension ".NEW." Example:'
Say ' '
Say ' D:\OS2\APPS\OS2CHESS.INI is cleaned into D:\OS2\APPS\OS2CHESS.NEW'
Exit
/* End of file */