EVAL javascript:exec() not working in my macro

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
JonnyDee
Posts: 17
Joined: Tue Jun 10, 2014 4:51 pm

EVAL javascript:exec() not working in my macro

Post by JonnyDee » Sat Jul 19, 2014 2:49 am

This is a progression from another thread where I was trying to start a javascript process with iMacros.

My solution has a small problem: the overall process works except for this small annoyance that isnt ----


If I manually start harmonize.bat, it runs perfectly :roll: , but I have no happy with iim/eval

The macro is part of a larger html/javascript process, and everything after and before this macro are just fine


iret = iim1.iimPlay("execute_bat");

execute_bat.iim contents ..
.

Code: Select all

SET !EXTRACT NULL
SET exeBAT EVAL (" var X = (javascript:exec(\'I:\\harmonize.bat\');)  X; ")

EVAL runs in imacros browser without a reported error,
but the IE browser doesnt start as expected and there is no output from the bat file :shock: :? :evil:
All that happens is that the PROMPT shows the EVAL code .. not seen that before

This is the harmonize.bat === .
.

Code: Select all

"start iexplore http://127.0.0.1:3000/not_harmonized.txt/process.json"

any suggestions gladly received, :idea: :) :!:
JonnyDee


iMacros v9.00.2379 EE
Win 7 Ult x64 sp1 (updated tuesday)
workhorse iMacros Browser
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL javascript:exec() not working in my macro

Post by chivracq » Sat Jul 19, 2014 1:44 pm

Things I can think of...:
- Does your BAT File work if you launch it manually?
- In your BAT File, I'm surprised not to see the Path for iexplore.exe (and without the ".exe" Part)...
- Try removing the "start" in your BAT File or use it with the /B Switch together with an empty Double Quotes.
This is a working BAT File that I use (on Win7-64, the 'timeout' Statement won't work on WinXP...):

Code: Select all

start /B "" "C:\Program Files (x86)\Pale Moon\palemoon.exe"
timeout 30
ECHO Now running the macro (in a 2nd Tab)...
"C:\Program Files (x86)\Pale Moon\palemoon.exe" imacros://run/?m="_My Macro!.IIM"
or just:

Code: Select all

"C:\Program Files (x86)\Pale Moon\palemoon.exe" imacros://run/?m="_My Macro!.IIM"
- 'EVAL()' is rather for Data Manipulation, I would think... Try using 'URL GOTO' + Local File.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: EVAL javascript:exec() not working in my macro

Post by Tom, Tech Support » Mon Jul 21, 2014 1:27 pm

Why do you need to launch a batch file from a macro in the first place?

Since you are already using the scripting interface, you can use whatever provision is built into your programming/scripting language for running an external process. For example, in VBScript you would use the following:

Code: Select all

Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")

WshShell.Run "iexplore http://127.0.0.1:3000/not_harmonized.txt/process.json"
And since you are launching a new instance of IE, you could also use the iMacros scripting interface to do this:

Code: Select all

Dim im2, iret
Set im2 = CreateObject("iMacros")

iret = im2.iimOpen("-ie")
iret = im2.iimPlayCode("URL GOTO=http://127.0.0.1:3000/not_harmonized.txt/process.json")
Trying to call a batch file from a macro just seems like the incorrect, difficult approach if you ask me.
Regards,

Tom, iMacros Support
JonnyDee
Posts: 17
Joined: Tue Jun 10, 2014 4:51 pm

Re: EVAL javascript:exec() not working in my macro

Post by JonnyDee » Sat Jul 26, 2014 5:01 am

Hi chivraq!

Thanks for the suggestions ...
chivracq wrote:Things I can think of...:
- Does your BAT File work if you launch it manually?
Already stated that it does
chivracq wrote:- In your BAT File, I'm surprised not to see the Path for iexplore.exe (and without the ".exe" Part)...
- Try removing the "start" in your BAT File or use it with the /B Switch together with an empty Double Quotes.
It has been a long time since I used bat files, so I relied on the Microsoft tech forums for examples to borrow from. There are lots of different ways to use cmd.exe, some more dangerous than others. :lol:
chivracq wrote:- 'EVAL()' is rather for Data Manipulation, I would think..
EVAL can do anything javascript can do, AFAIK: I have used it a lot for logic and loops, and swapping strings,
never on data. Or perhaps I don't understand what you consider as data ??

chivracq wrote: Try using 'URL GOTO' + Local File.
Have you tried starting a bat file that way? See my results at bottom of post
Tom, Tech Support wrote:Why do you need to launch a batch file from a macro in the first place?
Trying to call a batch file from a macro just seems like the incorrect, difficult approach if you ask me.
Hi Tom,

Thanks for your input .... this was a step along the way to have a batch file to kill IE if running, start CCleaner and a custom cleaner, then iMacros/IE, and then a VPN/proxy service. The .bat would run at windows login, and also as a restart if initiated by a rule in a macro or a script. No, I haven't gotten to the point of writing the .bat ... still learning node.js ..
Tom, Tech Support wrote:Since you are already using the scripting interface, you can use whatever provision is built into your programming/scripting language for running an external process. For example, in VBScript you would use the following:

Code: Select all

Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")

WshShell.Run "iexplore http://127.0.0.1:3000/not_harmonized.txt/process.json"
And since you are launching a new instance of IE, you could also use the iMacros scripting interface to do this:

Code: Select all

Dim im2, iret
Set im2 = CreateObject("iMacros")

iret = im2.iimOpen("-ie")
iret = im2.iimPlayCode("URL GOTO=http://127.0.0.1:3000/not_harmonized.txt/process.json")
Point taken ... might be forced to use vbs if that is to only way to initiate the bat: my research seems to indicate that I cant run an executable via javascript {something with having to protect someone doing a C:\ format} and node.js seems to be keeping that rule.

Respectfully, to me it looks like everything offered as a solution is still initiating a javascript function, not a bat file. I will have to take responsibility for that as my subject for the thread was not explicit enough. Sorry, my bad :oops: :( :cry:

Smile everyone! Its my birthday :!: :shock: :o :wink:
Post Reply