Access Violation in Cmd.exe in Long Batch Files Using "FOR /F"

ID: Q250998


The information in this article applies to:
  • Microsoft Windows NT Workstation version 4.0
  • Microsoft Windows NT Server, Enterprise Edition version 4.0
  • Microsoft Windows NT Server version 4.0


SYMPTOMS

When you are running complex batch files for a long time (to run routine jobs, monitor services, and so on), and the batch files contain the for /f command to process files line-by-line and run commands using the line contents as parameters, you may receive "access violation" and "access denied" error messages in Cmd.exe


CAUSE

When you run the batch files for a long time, the reuse of memory areas by the program is more likely. In this case, the memory is not "nulled out" by the operating system. The algorithm used by Cmd.exe to extract tokens used as parameters for the command in the for /f command is vulnerable to reused memory.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next Windows NT 4.0 service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The English-language version of this fix should have the following file attributes or later:

   Date       Time     Size      File name   Platform
   --------------------------------------------------
   01/25/00   08:51a   208,144   Cmd.exe     Intel
   01/25/00   08:50a   357,648   Cmd.exe     Alpha 


WORKAROUND

This problem is aggregated by the changes in Heap Manager introduced in Windows NT 4.0 Service Pack 4. You should be able to avoid the problem by using the workaround described in the following Microsoft Knowledge Base article:

Q195009 Application Access Violation or Hang After Applying SP4


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbbug4.00 kbfix4.00
Version : winnt:4.0
Platform : winnt
Issue type : kbbug


Last Reviewed: January 26, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.