Make sure your PATH environment variable is 250 characters or less.
That's it! You can type "path" in the command prompt to see how big it currently is, and set up a batch file invoke a prompt with a more limited path to work around this problem.
In general, restricting the PATH size will prevent any program that uses DOS4GW from crashing immediately.
