Page 1 of 1
Batch tasks in Windows
Posted: Wed Mar 05, 2014 12:44 pm
by StephenTaylor
What's the simplest way to launch a batch job in Windows from Dyalog? That is, execute a Windows shell command that will run to completion without further interaction with the Dyalog task that launched it.
(In APL+Win a left arg to ⎕CMD is all I need for the ⎕CMD to return immediately after launch.)
Re: Batch tasks in Windows
Posted: Wed Mar 05, 2014 4:13 pm
by AndyS|Dyalog
Dyalog uses the left argument of ⎕CMD and ⎕SH (these two are synonymous) to initiate Auxiliary Processors. If you want to control what happens when calling a batch file or other command under Microsoft Windows, you need to specify the right argument to be a nested vector of two elements. The first element defines the command to be called, and the second the "Windows parameter". The full details can be found at
http://help.dyalog.com/13.2/index.htm.
There are some gotchas with the command string which we will be detailing in the forthcoming 14.0 documentation .. if you have problems drop support an email and we'll see what we can do.
Re: Batch tasks in Windows
Posted: Thu Mar 06, 2014 7:38 am
by Morten|Dyalog
As an alternative, if you are happy to be constrained to Microsoft.Net, you can use the System.Diagostics.Process class, which will give you lots of information to look at and buttons to press:
Code: Select all
⎕USING←',system.dll'
notepad←System.Diagnostics.Process.Start⊂'notepad.exe'
notepad.(Responding HasExited)
1 0
notepad.Kill ⍝ boom!
notepad.⎕nl -2
BasePriority Container EnableRaisingEvents ExitCode ExitTime Handle HandleCount HasExited Id MachineName MainModule MainWindowHandle MainWindowTitle MaxWorkingSet ...etc etc...
notepad.⎕nl -3
BeginErrorReadLine BeginOutputReadLine CancelErrorRead CancelOutputRead Close CloseMainWindow CreateObjRef Dispose ...etc etc...
Re: Batch tasks in Windows
Posted: Tue Mar 11, 2014 4:12 pm
by StephenTaylor
Andy, thanks. Using 'Hidden' as below:
⎕CMD 'C:\domything.exe C:\to\this\file.dat' 'Hidden'
returns execution immediately to APL, leaving the EXE to run. The CHM says of 'Hidden':
Application is run in an invisible window.
Might be useful to extend that:
Application is run in an invisible window and ⎕CMD returns immediately.