From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!6Wzk4cIOQzbtIfSd/aOQqg.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to call a Windows executable from Ada? Date: Thu, 9 Dec 2021 08:29:19 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <71f3752c-40a2-4678-9451-1223a776b384n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="50533"; posting-host="6Wzk4cIOQzbtIfSd/aOQqg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63209 List-Id: On 2021-12-09 00:04, Marius Amado-Alves wrote: > Any *effectively working* solution for calling an external Windows executable, with arguments, from inside Ada? > > For example, the following command runs fine when given on the Windows command line: > > "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE" /f "C:\long path\with spaces\and accented letters\like in the words\declaração de autorização.docx" /mSave_As_Txt > > The same command FAILS when called from inside Ada with any of the know "solutions" on GNAT gem [1] and Rosetta Code [2]. I doubt very much that GNAT.OS_Lib.Non_Blocking_Spawn does not work. You do something wrong, like passing quotation marks etc. Remember, Windows does not have argument lists Linux have. So all UNIX-esque calls like Non_Blocking_Spawn are ultimately assembled back into a single command-line which is then split back again inside the process. Thus dealing with quotation marks you must make it sure that they are not get eaten or introduced. As for other ways, if you need access to input/output/error of the process you can use GLib primitives: http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#10 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de