Soffice won't run .ods file with macro from command line

I am a new LO user trying to move from OO, and need to start LO Calc from Windows 10 .cmd files.

After a cd to C:\Program Files\LibreOffice 5\program, I’ve tried the following soffice commands with the indicated results:

soffice --help

This command works correctly and displays all of the soffice options in a window.

soffice --calc

This command works correctly and creates an empty spreadsheet.

soffice --norestore --nodefault path_to_my_.ods_file

This command fails and displays the message “C:\Program Files\LibreOffice 5\LibreOffice does not exist”.
The complaint is true since there is no LibreOffice file in the LibreOffice 5 directory.
The path_to_my_.ods_file has been verified with the “if FileExists…” command .
I installed version 5.3.7.2 (64-bit). OpenOffice is still installed.

Cannot reproduce with 5.4.3.2, even when cd to the C:\Program Files\LibreOffice 5\program (but why would that be req’d? you can call “C:\Program Files\LibreOffice 5\program\soffice.exe” from any directory…)

I decided to cd to the Libre Office 5\program directory because before I did that, I was getting an error message that said something to the effect that LO was unable to access its primary control information. After I added the cd, that problem disappeared.

I have since been able to get the following command to open the SS, but the macro is not executed:
soffice.exe [switches] [path to .ods file] macro://[path to .ods file]/Standard.Starter.[macro name]
which is similar to what I have been using successfully with OO.
I’m going to revert back to my original approach (as Mike suggests) in which I cd to the directory containing all of my SSs and .cmd files and see how LO responds.

I finally got everything right and am now able to open the SS and execute the desired macro. The final command in my .cmd script is:

“C:\Program Files\LibreOffice 5\program\soffice.exe” --nologo --norestore --nolockcheck
%1.ods macro://%1/Standard.Starter.CmdA

where %1 is the file name of the SS (without the .ods) and CmdA is the name of the macro in the SS.
The first reference to %1 requires the .ods to complete the path, but the second reference (in the full name of the macro) is a reference to the document object and must not include the .ods.

I was also able to replace the call to soffice.exe with a direct call to scalc.exe instead, assuming that this eliminates a small amount of overhead.

Windows command line allows to simplify taking the file name without the extension, to make the command more flexible (avoiding the hard-coded ODS extension):

“C:\Program Files\LibreOffice\program\soffice” --nologo --norestore --nolockcheck %1 macro://%~n1/Standard.Starter.CmdA

Or even better - avoid mentioning the current document name at all: use . for the name - that is portable, like this:

“C:\Program Files\LibreOffice\program\soffice” --nologo --norestore --nolockcheck %1 macro://./Standard.Starter.CmdA

Regarding to this:

I was also able to replace the call to soffice.exe with a direct call to scalc.exe instead, assuming that this eliminates a small amount of overhead

The assumption is wrong.

It seems kind of strange to see a comment posted to a problem solved correctly on Nov 11 '17 (it’s now Jul 7 '20), especially when the points made in the comment add nothing useful to the solution.

@Herb40: Ask is about helping not only to someone asking the question, but also to anyone who later happens to look for the same. I happened to come across this question, and found it potentially useful to people to mention ways to solve this in a more generic way.

And it’s especially justified exactly because this is solved. Because people will search for questions with answers.