I start Libre Office with (for example):
call start “C:\Program Files\LibreOffice 7\program\soffice --writer %1”
(I also tried ‘start’ without ‘call’ and calling the program directly, without ‘call start’).
It works fine, but it does not return control to the command line until I exit Libre Office.
Normally, ‘call start’ starts a program and does return control immediately.
If anyone can tell me how to accomplish this, I’d be thankful.
Program only returns control to the calling program if it’s not a proper console program. Console programs normally do not return to command prompt after starting; and since version 6.3, LibreOffice got a proper console mode that starts when you call it from command prompt without specifying exe
extension.
Just use "C:\Program Files\LibreOffice 7\program\soffice.exe" --writer %1
, specifying the exe
explicitly, to have the desired behavior. Note that if you use LibreOffice in command-line mode, like using --convert-to
, you would likely not want it to return to command prompt until it’s finished - so that it has a chance to output whatever error messages it has for you; in that case, you likely would want to use the program name without extension (or using com
extension instead, which is what gets called when you do not specify the extension in cmd.exe
).
To start from a batch file (which does not return until the launched program terminates), note that start command takes its first argument as title, so pass some title there before specifying the command:
start "" "C:\Program Files\LibreOffice 7\program\soffice.exe" --writer %1
Also notice the /wait parameter of the start command.
Thanks for the answer, Mike.
I’m afraid that call did not work. Command did not return to the command line.
I think I might not have emphasized enough that I am trying to call FROM A BATCH FILE. Perhaps that is significant.
But, of course, the presence of “%1” indicates that a batch file is involved.
Calling directly from the command line does work as you’ve indicated
I tried the following, in a batch file:
“C:\Program Files\LibreOffice 7\program\soffice.exe” --writer %1
(Command did not return)
call “C:\Program Files\LibreOffice 7\program\soffice.exe” --writer %1
(Command did not return)
call start “C:\Program Files\LibreOffice 7\program\soffice.exe” --writer %1
(Error: “The system cannot find the file --writer.”)
I also tried calling swriter with similar wordings; same disappointing results.
I’d appreciate any other suggestions. Thanks in advance.
EDIT TO THIS RESPONSE: SOLVED, WITH A MYSTERY OF SORTS.
Thanks for the responses. The key is Mike’s observation regarding the use of ‘start.’ I experimented with ‘start " "’, as he suggests. It works, but, curiously, note how the invocation of ‘soffice’ triggers an unwelcome error window, while the invocation of ‘swriter’ works flawlessly.
The following two commands–
start " " “C:\Program Files\LibreOffice 7\program\soffice” %*
start " " “C:\Program Files\LibreOffice 7\program\soffice” --writer %*
both work, but they produce a pop-up window with the message “vkEnumeratePhysicalDevices failed: -3”. Silly of me not to think of that beforehand.
I was unable to suppress the error window by using “>nul” and “>nul 2>&1”.
By contrast, the following works as expected. It starts Writer and returns control to the command line, without any error message:
start " " “C:\Program Files\LibreOffice 7\program\swriter.exe” %*
Thanks again for the responses.
- Your reply is not a solution to your problem, and should be a comment.
- You wrote:
call start “C:\Program Files\LibreOffice 7\program\soffice.exe” --writer %1
(Error: “The system cannot find the file --writer.”)
Of course. Check help for start, which treats its first argument as a title. Just use
start "" "C:\Program Files\LibreOffice 7\program\soffice.exe" --writer %1
start " " "C:\Program Files\LibreOffice 7\program\soffice" %*
start " " "C:\Program Files\LibreOffice 7\program\soffice" --writer %*
both work, but they produce a pop-up window with the message “vkEnumeratePhysicalDevices failed: -3”.
The error looks related to Vulkan. Possibly you need to disable Skia, or to force its software mode.
Additionally, related to the Vulkan issue (the message itself, and inconsistency in behavior of soffice.exe
vs swriter.exe
), you should file a bug to the bug tracker to allow fixing it.