The MaxL “Repeated calls to startMaxl.bat stops working” on Windows issue

I’ve run into this before and a few colleagues have recently run into this. Sometimes you’ll write some MaxL automation that loops a lot, for example, looping over a bunch of input files (perhaps you have a single text file per day of data or something).

So in your batch file you have a for loop or just a bunch of repeated calls to startMaxl.bat (note that startMaxl.bat is a wrapper of sorts for essmsh, the MaxL interpreter). The first X number of runs work just fine, then all of a sudden new calls to the script stop working. Closing the command prompt window and reopening it “fixes” the issue.

In the past when I bumped into this it was very tricky to troubleshoot. Let’s look at the code for startMaxl.bat:

@ECHO OFF
@REM This file is created to startMaxl
rem Set ESSBASEPATH
call "%~dp0\setEssbaseEnv.bat"
set PATH=%ESSBASEPATH%\bin;%PATH%
%ESSBASEPATH%\bin\essmsh.exe %*

Nothing too fancy, but notice that second to last line – where we are setting the PATH to be the ESSBASEPATH variable PLUS the existing PATH. This is a fairly common pattern. The problem, though, is that Windows has a limit to how long the value of a variable can be. The repeated calls to startMaxl are increasing the size of the PATH variable in that environment (i.e., the changes aren’t permanent) and once the length limit is hit, the job fails.

The workaround? There’s a couple. If you can call essmsh directly then use that. Sometimes you get a “MaxL initialization error” or similar  – this is due to environment variables not being set (check the setEssbaseEnv.bat file for the variables that need to be set). You can add these to your system variables and call essmsh directly. Alternatively we could change startMaxl or create a new file next to it that will only append the PATH once (say, by tracking this in another temporary variable).

Just wanted to pass this on since it ca be a little tricky to troubleshoot. Good luck!

 

2 thoughts on “The MaxL “Repeated calls to startMaxl.bat stops working” on Windows issue

  1. Hi Jason,

    Thanks for your post. I actually have a quick question. I want to add date inside a txt backup script so it would give me something like this
    ExpLev0_P_BSO.Plan1_06-06-2017.txt
    We know that in Maxl if its a huge application it would give us _1, _2 after it hits 2.00 gb of file. So instead of ExpLev0_P_BSO.Plan1, ExpLev0_P_BSO.Plan1_1.txt, ExpLev0_P_BSO.Plan1_2,.txt I want this ExpLev0_P_BSO.Plan1_06-06-2017.txt
    ExpLev0_P_BSO.Plan1_1_06-06-2017.txt
    I would appreciate any help.
    Thanks

  2. Hi Sara,

    I think the trick in your case is going to be to export the file(s) with just a “plain” name on them (meaning no date), then run a small batch file that will take all of the export files and rename them to include the data you want. This should arrange the filename how you want it, although there isn’t a way to get what you want directly with MaxL (it’ll be MaxL plus some batch file scripting). But it shouldn’t be too difficult.

Leave a Reply

Your email address will not be published. Required fields are marked *