I am trying to automate the batch process wherein once I export results of explorations to csv files (multiple files), I open these files which in turn are linked to an EXCEL file. The process is quiet fast as for the command line but the drawback is since multiple OPEN commands are passed it sometimes over-runs wherein a few of the csv files get OPEN in READ only. A way out in my opinion is to introduce a lag either through "SLEEP & ECHO" , but am still not clear how the syntax would work. Can anybody guide a bit. The base "execute & wait" command would look something like below:
cmd.exe /c start excel "D:\Daily Datapoints\07 - OPT Val Macro-Micro-MWPL\07 Raw\MAC.csv"
cmd.exe /c start excel "D:\Daily Datapoints\07 - OPT Val Macro-Micro-MWPL\07 Raw\MACB.csv"
cmd.exe /c start excel "D:\Daily Datapoints\07 - OPT Val Macro-Micro-MWPL\07 Raw\MWPL.csv"
Pause
cmd.exe /c start excel "D:\Daily Datapoints\07 - OPT Val Macro-Micro-MWPL\07 FO Val Macro-Micro.xlsx"
The "Pause" here stops till manual intervention in not done, I just want to put in SLEEP &/or ECHO inside the surface flow
You can probably use that to pause multiple seconds as needed or until a key press (using -1 as a parameter).
Use it in a execute and wait line.
I did not test it but I think it will work.
At the command prompt type: timeout /? to get the command syntax.
P.S. Searching for it on StackOverflow I see this note: “Timeout is poorly implemented. If you do a “timeout 1”, it will wait until the “next second,” which could occur in .1 seconds. Try doing “timeout 1” a few times and observe the difference in delay. For 5 seconds or more, it may not be a big deal, but for a 1 second delay it works poorly. (Dan)”
There is Pause command in the Batch processor already. You can use JScript to sleep for specified number of seconds, you can put all your command line calls into single BAT file. There are literally dozens of possibilities.
@pushkan, I’m not sure to understand the issue (the confirmation dialog screenshot you posted does not show “Update” or “Save” buttons) but I suggest you do to some Google searching!
(This seems to be out of the realm of AB):
For instance typing “Excel how to automatically update external links without a confirmation dialog” I found:
So far so good. The system works well on a local machine, however when run from a network drive, it holds back as the file opens as “Read Only” thereby not updating my final excel sheet.
While on the matter, is there any way to save changes and then close (taskkill) the said file after saving?
@pushkan what “file”?
Are you referring to the (multiple) .cvs files written by the exploration? Are these the files that are in “read-only mode” when you attempt to open them from a network machine?
In such a case, are you able to copy these file (test this both locally and/or to a remote/network destination) using a standard DOS command line copy command and then open the copied file in the required application (Excel)?
Initiating an alternate reply as only 1 image is allowed per post
However in the next step stuck that with file being locked for editing by "another user". Actually there is no such user, as I tried by disabling the "Sharing"
Yes indeed it's a BUG on earlier versions of Office &/or Windows. Upgrading to Office 2010 helped.
Thanks Tomasz,
The issue is way beyond the purview of Amibroker, but the forum helps get through the roadblocks.
Though not directly related to topic would like to know how to run an exe file in a specified folder, through the batch file process. The default path is set to "C:\Program Files\Amibroker", hence If I run in the command as cmd.exe /c start ITMCDRun.exe
it will run succesfully. But I wish to run it through a specified folder like
cmd.exe /c start "E:\Converters & Downloaders\ITM CD JAN 2018\ITMCDRun.exe"
NOTE The Above syntax is for the ShellExecute function when called from AFL formulas not for the "Batch" Execute & Wait operation (as per your screenshot). I missed that point from you previous message, sorry!
The easiest way to use it from an AmiBroker batch is to launch a DOS/Windows batch file in which you do all the necessary steps (including changing the working folder). This was already suggested above by @Tomasz.
For example to launch it from the "Batch" Execute & Wait I entered:
C:\\dev\\lazarus\\laz.bat
and create a "laz.bat" in the the above folder (C:\dev\lazarus) as follow:
An add-on, would it be possible to trigger an exe on different machine. Idea is not to open the instance of exe in current machine, but it should open in the other machine itself.