On Windows 7, when I used process_create/3 in SWI Prolog to open an application like Notepad.exe, the notepad opens. However, it doesn't work for applications that use command prompt. As an example, when I tried to open the command prompt window, using:
main :- process_create('C:\\WINDOWS\\system32\\cmd.exe',[] ,[]).
which gives an
ERROR: Process "c:\windows\system32\cmd.exe": exit status: 1
Similarly, when trying it to open powershell.exe, it doesn't work either. the console just hangs, without displaying an error.
Any help is greatly appreciated.
To start a separate console window:
Or even shorter (but I don't know how portable this is):
Or this way (idea taken from SWI-Prolog source code):
To start an external BAT command with 3 arguments:
Important note: theoretically you could pass all this arguments as one string, eg.
'/c start cmd ...'
instead of list of strings but strange things may happen in more sophisticated cases. In my case SWI-Prolog 7.2.3 added single quote or single double quote at the end, so the last argument passed to batch script was notarg3
butarg3'
orarg3"
.