Page 1 of 1

es.exe with regex from JScript

Posted: Tue Mar 21, 2017 12:54 am
by aussieboykie
I am using a JScript to run a query using es.exe and writing the output to a temp file. When I execute the following non-regex query..

es.exe -export-txt C:\Users\Me\AppData\Local\Temp\es.txt thunderbird.exe

..the expected output is written correctly to the es.txt temp file. However, when I use the -r option to introduce regex into the mix...

es.exe -r -export-txt C:\Users\Me\AppData\Local\Temp\es.txt thunderbird.exe

..nothing is written to the temp file. Executing exactly the same regex query from a DOS command line works just fine.

Any idea what I might be doing wrong?

Regards, AB

Re: es.exe with regex from JScript

Posted: Tue Mar 21, 2017 4:17 am
by ovg
I maybe wrong, but shouldn't you escape "\" with "\" when calling from JS?

Code: Select all

C:\\Users\\Me\\AppData\\Local\\Temp\\es.txt thunderbird.exe

Re: es.exe with regex from JScript

Posted: Tue Mar 21, 2017 6:07 am
by aussieboykie
That would not explain how or why it works without the -r option.

Interestingly, after further monkeying around, I have been able to get it working using a different approach. The way I was doing it is...

Code: Select all

var objWShell = new ActiveXObject("WScript.Shell");
objWShell.Run("cmd /c " + str, 0, true);
..where str is along the lines of..

pushd c:\esfolder & es.exe -options search-term & popd

I changed to create a three line C:\my.cmd file...

Code: Select all

pushd c:\esfolder
es.exe -options search-term
popd
..which I then execute using the same technique

Code: Select all

var objWShell = new ActiveXObject("WScript.Shell");
objWShell.Run("cmd /c C:\my.cmd", 0, true);
This works with the -r option.

Regards, AB