WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System INI and INI File Topics

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Writing DEVICE= Entries in System.INI

Keywords:   SYSTEM.INI

Question:

I seem to be having an issue with WinBatch and the SYSTEM.INI. I cannot guarantee it is WinBatch causing it, but I am pretty sure.

We use WinBatch for an automated login procedure, and it works REALLY well. We have started to receive some problems on people's Win95 PC. The computer will start to boot, but halt just before loading the GUI. The message "Not enough extended memory to run Windows" is displayed and it just hangs. Inspection at the end of the system.INI shows hundreds of pages of the following:


[TTFontDimenCache]
0 12=5 12

[TTFontDimenCache]
0 13=6 12
(Numbers vary, but you can see the structure).

Client OS: Win95
WinBatch version: 96M

This network login procedure has modified system.ini for about 12 months with no issues. We use IniWritePvt to modify the system.ini.

Do you know what generates these entries? Thanks once again for the fantastic support.

Answer:

  1. How is WinBatch involved. Do you run a script that modifies the system.ini file? Do you use IniWritePvt, the Binary Functions, or FileWrites.

  2. Do you use the DOS BAT file iniwrite.com to update the system.ini file? OLD OLD OLD versions of iniwrite.com (For Windows 2.0) may not be compatible with current versions of windows. (We have not distributed iniwrite.com in 3 or 4 years)

  3. In general, as long as you stay away from the [386Enh] Device= lines of the system.ini, the IniWritePvt does a good job. The change [386Enh] Device= lines, use Binary method below.

    We've seen occasional problems where a non-dos compatible editor (defined as putting a CRLF after every line) is used to edit the file and only puts a LF after some of the lines. Slow cannabilization of the ini file starts. But the symptoms are different from what you describe. I've heard of no other reports of anything like that.

  4. You may wish to add a:
    
    IniWritePvt("","","","system.ini")
    
    to force an immediate write of the system.ini to disk after the update.

  5. P.S. IniWritePvt and FileWrite and FileCopy operations are not always compatible, as the system caches the ini data for some time. Forcing the write to disk alleviates a lot of problems.

More SYSTEM.INI Info:

Question:

I figured out how to write to my system.ini with BinaryPokeStr. But I'm still having difficulty with IniDeletePvt. Does this command work on sys.ini ?

  • I'm new to programming so you will have to bare with me. I am using the BinaryWrite because I have to remove the DEVICE= lines in my sys.ini. and write new ones in.

  • Program one needs the sys.ini set up one way and program two needs it set up another way.

  • I read you message four times and I still can't figure out what command I would use to REMOVE the Device= lines.

    I have no idea how to delete the 386 Enh section of the sys.ini and replace it with a new one.

Answer:

I suspect the BinaryFunctions are editing the fake copy, and the IniDeletePvt is affecting the registry versions of it. The SYSTEM.INI is often mapped to the registry and a SYSTEM.INI-appearing file is maintained in the system directory.
  1. File operations (like BinaryWrite) and INI operations live in different worlds. To make things work correctly you have to sync them up.

  2. If you are doing a bunch of iniwrites and then want to perform a file operation on the file, then you need to:
    
    iniwritepvt("","","","inifilename.ini")
    
  3. If you are writing a file and want the ini system to sync up, I think you just do an INIREADPVT of one of the items you modified. (And maybe verify the change took place to be extra careful.)

  4. You only really need to be using the Binary stuff if you are modifying a device=line in SYSTEM.INI. So you will have to use the BinaryFunctions to remove the unwanted device=keyword lines.

    The BinaryFunctions are kind of a rough introduction to programming. I would...Read all the binary functions. Copy the examples. Run them. Understand exactly how they work. See:

    
    http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/How~To/System~INI~and~INI~File~Topics+System~Ini~~-~Writing~multiple~device~lines~to.txt 
    

    Make a copy of your system.ini. Try editing the copy. Look at it carefully. Make sure the edits worked. Try other cases.

  5. SYSTEM.INI is not a 100% kosher ini file. The multiple device=lines make it illegal. But a lot of stuff works if you stay away from device=keyword lines.

  6. I would hesitate mixing file operations with BinaryOperations without a maybe 20 seconds delay between them.

    KEEP GOOD BACKUPS FOR A WHILE OF THE SYSTEM.INI FILE UNTIL YOU FINISH THE CHANGES!!!

Basic Methodology on How to Edit DEVICE= Lines in SYSTEM.INI:

The BinaryFunctions are general-purpose functions wherein you get to manage a large chunk of raw computer memory. There is the ability to read a file into a Binary Buffer, and to dump the contents of a BinaryBuffer to a file.

It is just incidental that they can be used to edit the system.ini file device = section.

  1. The general method would be to allocate two binary buffers, both slightly larger than you need (get the Filesize of SYSTEM.INI and add some kind of suitable fudge factor.)

  2. Read the system.ini into one of the BinaryBuffers. Using probably some version of BinaryIndexNC. Locate the beginning and the ending of the block you wish to delete.

  3. BinaryCopy the front of the file to the second binary buffer. BinaryPokeStr the new section (or Allocate a third buffer, read in the changes and BinaryCopy those to the second buffer). Then figure out what is left in the file and binarycopy that to the second buffer.

  4. Write out the second buffer as your new file.

    An alternate way to update system.ini directly might be with FileRead/Write operations:

    
    filein = FileOpen("c:\windows\system.ini","READ")
    fileout = FileOpen("c:\windows\system.out","WRITE")
    line = ""
    While line <> "*EOF*"
        line = StrTrim(FileRead(filein))
        If StrSub(StrUpper(line),1,7) == "DEVICE=" Then Continue ; don't write Device lines
        If StrSub(StrUpper(line),1,7) == "DEVICE " Then Continue
        FileWrite(fileout, line)
    EndWhile
    FileClose(filein)
    FileClose(fileout)
    FileCopy ("c:\windows\system.out","c:\windows\system.ini",0)
       
    ;the above writes every line, except those that begin (excluding leading spaces)
    ;device= or device = or device settings = etc.
    ;further line checking is possible.
    ;you can also check for sections, so that you only do it within
    ;[386Enh] section or whatever
    

    I think the system.ini - especially the device= section - is mainly referred to at system bookup time - not while it is running. So you will have to reboot your computer after the changes.

    Modifications to device= lines will not take effect until the next time you boot up the computer. So you could either modify it then reboot, or in the autoexec.bat file, before windows really gets going - swap in the desired system.ini there. But I think the best way is to have two SYSTEM.INI files, as is discussed below.

Now the trick: Two SYSTEM.INI Files:

OK, you get two different system.ini files. One for each app. We'll call them APPA.INI and APPB.INI

Add a new section to both files (with notepad) like thus:


[WHOAMI]
IAM=APPA (or APPB in the other one)
So your WinBatch script would work like this. (You can make a more elegant script that this, but this will get you started.)


;=======snip============
whoami=IniReadPvt("WHOAMI","IAM","???","SYSTEM.INI")

ans=AskYesNo("%whoami% INI file loaded","Press YES to load
        APPA%@CRLF%Press NO to load APPB %@CRLF%Press Cancel to quit")

APPAINI="c:\windows\appa.ini"
APPBINI="c:\windows\appb.ini"
system="c:\windows\system.ini"

If ans==@YES
  FileCopy(APPAINI,SYSTEM,0)
else
  FileCopy(APPBINI,SYSTEM,0)
endif

IntControl(67,0,0,0,0)
;============snip==============
Then to reboot automatically, use:

IntControl(67,0,0,0) 
is safe.

IntControl(67,0,1,0,0) 
is not.
Article ID:   W13345
Filename:   Writing to the System INI file.txt
File Created: 2017:08:29:11:59:00
Last Updated: 2017:08:29:11:59:00