Batch tasks in Windows

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
Post Reply
User avatar
StephenTaylor
Posts: 31
Joined: Thu May 28, 2009 8:20 am

Batch tasks in Windows

Post 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.)
User avatar
AndyS|Dyalog
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: Batch tasks in Windows

Post 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.
User avatar
Morten|Dyalog
Posts: 460
Joined: Tue Sep 09, 2008 3:52 pm

Re: Batch tasks in Windows

Post 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...
User avatar
StephenTaylor
Posts: 31
Joined: Thu May 28, 2009 8:20 am

Re: Batch tasks in Windows

Post 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.
Post Reply